Hi.
The code i'm using below lists all records as follows:
Name ID Number Company Name
john smith 1 ICBC
etc.
I need to be able to click on the id number and open an edit page for that specific record. I'm not sure how to go about doing that. I'd appreciate any help you may be able to offer. thx.
<?php
echo "<TABLE BORDER=\"0\" cellpadding=\"2\" cellspacing=\"2\">\n";
echo "<TR ><TD>Name</TD><TD>ID Number</TD><TD>Company Name</TD></TR>\n";
for($i = 0; $i < $numofrows; $i++) {
$row = mysql_fetch_array($result); //get a row from our result set
if($i % 2) { //this means if there is a remainder
echo "<TR >\n";
} else { //if there isn't a remainder we will do the else
echo "<TR > \n";
}
echo "<TD>".$row['Name']."</TD><TD>".$row['IDNumber']."</TD><TD>".$row['CompanyName']."</TD>\n";
echo "</TR>\n";
}
//close table
echo "</TABLE>\n";
?>
link to and edit page with the record ID number
Moderator: General Moderators
Re: link to and edit page with the record ID number
If I understand correctly, change your code to:
echo "<TD>".$row['Name']."</TD><TD><a href="\edit.php?id=".$row['IDNumber']."\"edit</a></TD><TD>".$row['CompanyName']."</TD>\n";
Then, on the edit.php page, use the id url parameter as your key in in to the database (for your recordset).
echo "<TD>".$row['Name']."</TD><TD><a href="\edit.php?id=".$row['IDNumber']."\"edit</a></TD><TD>".$row['CompanyName']."</TD>\n";
Then, on the edit.php page, use the id url parameter as your key in in to the database (for your recordset).
Re: link to and edit page with the record ID number
That is what i want, but without the word edit. in dreamweaver, i'm getting a red line indicating an error in the code, so i'm not sure where the error is in the code you gave me.
Re: link to and edit page with the record ID number
Oops, I had my escape character out of order:
echo "<TD>".$row['Name']."</TD><TD><a href=\"edit.php?id=".$row['IDNumber']."\"edit</a></TD><TD>".$row['CompanyName']."</TD>\n";
echo "<TD>".$row['Name']."</TD><TD><a href=\"edit.php?id=".$row['IDNumber']."\"edit</a></TD><TD>".$row['CompanyName']."</TD>\n";
Re: link to and edit page with the record ID number
its getting close. but when i view the page. the id number now is blank.
i don't need an edit link, just when they click on the id number for the related page to open.
i don't need an edit link, just when they click on the id number for the related page to open.
Re: link to and edit page with the record ID number
ha, sorry again. fixed
echo "<TD>".$row['Name']."</TD><TD><a href=\"edit.php?id=".$row['IDNumber']."\">edit</a></TD><TD>".$row['CompanyName']."</TD>\n";
echo "<TD>".$row['Name']."</TD><TD><a href=\"edit.php?id=".$row['IDNumber']."\">edit</a></TD><TD>".$row['CompanyName']."</TD>\n";
Re: link to and edit page with the record ID number
thx for getting back to me. It's close 
I'm getting the following displayed:
john smith 'edit' ICBC
But i need it to be:
john smith '1' icbc
where, when they click on the idnumber (1) it goes to edit.php?id=1
I'm getting the following displayed:
john smith 'edit' ICBC
But i need it to be:
john smith '1' icbc
where, when they click on the idnumber (1) it goes to edit.php?id=1
Re: link to and edit page with the record ID number
I figured it out by
</TD><TD><a href=\"edit.php?id=".$row['IDNumber']."\">".$row['IDNumber']."</a></TD>
thx for your help.
</TD><TD><a href=\"edit.php?id=".$row['IDNumber']."\">".$row['IDNumber']."</a></TD>
thx for your help.
Re: link to and edit page with the record ID number
no prob. my code was just an example, not a solution. 