Jump to content

Recommended Posts

Hi,

 

I have a form that I have set up to INSERT data into, now am trying to set it up so that I can edit the data that has been entered.

 

My table output is via an echo which out puts all the table but I need to execute a small PHP script from there so that I can click on the update link and the row for data is selected from the database.

 

Here is the code;

 

// Database Connection

<html>
<title>View Contacts</title>
<center>
<table bgcolor="#0066FF" border="0" width="75%" cellspacing="1" cellpadding="2">
<?php
// Query for displaying data in the order of the persons last name
$query = "SELECT * FROM contacts ORDER BY last";
$result = mysql_query ($query, $connection);

for ($i = 0; $i < mysql_num_rows ($result); $i++)
{
	$first = mysql_result ($result, $i,"first");
	$last = mysql_result ($result, $i,"last");
	$company = mysql_result ($result, $i,"company");
	$town = mysql_result ($result, $i,"town");
	$email = mysql_result ($result, $i,"email");
	$email_len = strlen($email);

	if ($i % 2)
	{
		$bg_color="#EEEEEE";
	}
	else
	{
		$bg_color="#AAAAAA";
	}

	echo '
		<tr>
			<td width="30%" bgcolor="'.$bg_color.'">
				<font face="arial" size="2">';
					if ($email_len > 0)
					{
						echo '<b>First Name:</b> <a href="mailto:'.$email.'">'.$first.'</a>';
					}
					else
					{
						echo '<b>First Name:</b> '.$first;
					}
					echo '
					<br>
					<b>Last Name:</b> '.$last.'
					</font>
				<td>
				<td width="20%" valign="top" bgcolor="'.$bg_color.'">
					<font face="arial" size="2">
						<b> Email: </b> '.$email.'
					</font>
				</td>
				<td>
				<td width="20%" valign="top" bgcolor="'.$bg_color.'">
					<font face="arial" size="2">
						<b> Town: </b> '.$town.'
					</font>
				</td>	
				<td>
				<td width="20%" valign="top" bgcolor="'.$bg_color.'">
					<font face="arial" size="2">
						<b> Company: </b> '.$company.'
					</font>
				</td>
				<td>

// This is the line where I am trying to run this code within the echo...
				<td width="10%" valign="top" bgcolor="'.$bg_color.'"><a href="contact_edit.php?id=<?php echo $rows['id'];?>">Update</a>
					<font face="arial" size="2">
					</font>
				</td>
			</tr>
		';
}
?>
</table>

</center>

<body>
</body>
</html>

 

<td width="10%" valign="top" bgcolor="'.$bg_color.'"><a href="contact_edit.php?id=<?php echo $rows['id'];?>">Update</a>

 

Many Thanks for any help

Karl

<td width="10%" valign="top" bgcolor="'.$bg_color.'"><a href="contact_edit.php?id=<?php echo $rows['id];?>">Update</a>

 

You are using <?php tags inside of an echo. Concat it like King has done, or like you have done previously and it should work.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.