Pass variable from hyperlink click
Posted: Wed Jan 26, 2011 2:03 pm
I have a table that pulls all of a users products currently in the database. The user can click on the product name and be taken to an update page where they can update their product. What I need is to create and pass a variable based on what the user clicks so that I bring up the correct item to on the update page. Here is the table with product info and hyperlinks:
Most users will have numerous products. When they click on the 'prod_name' I want the update_product.php to pull up the info for only that product. I have the update_product built so I just need to get and pass the variable based on the click.
thanks,
tim
Code: Select all
<?php
$query = 'SELECT
prod_name, short_desc, long_desc, avail_date, country_origin
FROM
user_product u JOIN
product i ON u.prod_id = i.prod_id
WHERE
user_id = "' . mysql_real_escape_string($_SESSION['user_id'], $db) . '"';
$result = mysql_query ($query, $db) or die(mysql_error($db));
echo "<table border='1'>
<tr>
<th>Product Name</th>
<th>Short Description</th>
<th>Date Available in US</th>
<th>Product Manufactured In</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>";
echo ("<a href=\"update_product.php\">" . $row['prod_name'] . "</a>");
echo "</td>";
echo "<td>" . $row['short_desc'] . "</td>";
echo "<td>" . $row['avail_date'] . "</td>";
echo "<td>" . $row['country_origin'] . "</td>";
echo "</tr>";
}
echo "</table>";
?>
</div>
thanks,
tim