Passing id using an anchor
Posted: Sat Feb 28, 2004 8:23 am
Hi,
In the past you guys help me a lot and I hope someone will give me a solution to this problem. I have a problem passing variables from one php page to another. What I would like to do is, display data from the database as a table and create an anchor for each table data so that if I click on one table data it will pass the id to another page.
Here is the code
Please help
In the past you guys help me a lot and I hope someone will give me a solution to this problem. I have a problem passing variables from one php page to another. What I would like to do is, display data from the database as a table and create an anchor for each table data so that if I click on one table data it will pass the id to another page.
Here is the code
Code: Select all
<?php
$dbc = mysql_connect("localhost") or die ("Unable to connect to databse.");
$db = mysql_select_db("mydatabase") or die ("Unable to select database.");
$query = "SELECT asset.asset_id, asset.description, asset.asset_type, department.dept_name, department.asset_owner FROM asset, department WHERE asset.department_num = department.dept_id";
$result = mysql_query($query, $dbc) or die (mysql_error(). '<br> SQL: '.$sql);
print "<center>";
print "<table border=1><tr><th>Asset ID</th><th>Asset Name</th><th>Type</th><th>Asset Location</th><th>Owner's Name</th></tr>";
$i = 0;
while ($row = mysql_fetch_row($result))
{
print "<tr bgcolor='#F5EA9E' onmouseover=this.style.backgroundColor='#3165CE'; onmouseout=this.style.backgroundColor='#F5EA9E';>";
foreach ($row as $field)
{
$asset_id = mysql_result($result,i,"asset_id");
print "<td ><a href = 'editasset.php?id=$rowї$asset_id]'>$field</a></td>";
}
print "</tr>";
}
$i++;
print "</table>";
?>