Reputation: 15
while($row = mysql_fetch_array($result)) {
echo "<tr>";
echo "<td>" . $row['mf_id'] . "</td>";
echo "<td>" . $row['Manufacturer'] . "</td>";
echo "</tr>";
}
I want to make the Manufacturer column clickable and return the value of the corresponding mf_id
value to another page
Upvotes: 1
Views: 144
Reputation: 1518
I think this is what you are looking for.
Try this:
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . htmlspecialchars($row['mf_id']) . "</td>";
echo "<td><a href=\"yourlink.php?mf_id=" . htmlspecialchars($row['mf_id']) . "\">" . $row['Manufacturer'] . "</a></td>";
echo "</tr>";
}
So when you click the link you will be brought to the page "yourlink.php". If you want the value that was in $row['mf_id'] do this:
$mf_id = $_GET['mf_id']
$mf_id will now hold the value that was passed to the page.
Upvotes: 2
Reputation: 163301
You can use your variables in any context you want, including anchor tags:
echo '<td><a href="', htmlspecialchars('yourpage.php?mf_id=' . $row['mf_id']), '">',
htmlspecialchars($row['mf_id']), '</a></td>';
If you want to link the entire row, you will need a JavaScript click handler. Otherwise, simple anchor tags will do what you want.
Upvotes: 2