Full-service Internet Marketing & Web Development
Recent Posts

Sponsors
![]() |
Attaching Variables to LinksCode Wizard, 12-30-2006 |
Lets say u are selecting all data from a database for a listing, then u want to have a link that goes to the details of the record. This is the code you "Could" use to do so.
####### List.php ######
<?
$link = mysql_connect("host","user","pass");
$db = mysql_select_db("database", $link);
//* Get all records
$sql = "SELECT * FROM table";
$sql_result = mysql_query($sql,$link);
while ($row = mysql_fetch_array($sql_result)) {
//* In place of $id u would put the name of the column that u want displayed, remember you can use multiple columns when creating these
$id = $row["id"];
//* echo the link to html
echo "<a href="detail.php?name=$name&id=$id">$id</a>";
};
mysql_free_result($sql_result);
mysql_close($link);
?>
############ Detail.php ############
<?
$link = mysql_connect("$host","$user","$pass");
$db = mysql_select_db("database", $link);
$sql = "SELECT * FROM table where id = '$id'";
$sql_result = mysql_query($sql,$link);
while ($row = mysql_fetch_array($sql_result)) {
$detail = $row["detail"];
$detail1 = $row["detail1"];
$detail2 = $row["detail2"];
echo "
Detail : $detail
Other Detail : $detail1
MORE Detail : $detail2
";
};
mysql_free_result($sql_result);
mysql_close($link);
?>
|
|
Subscribe Now to receive new posts via Email as soon as they come out.
Comments
Post your comments

