I am trying to get the first name in my table to link to "user_info.php"
right now the way I built my table every attribute is a link.
any ideas on how to fix this?
here is my code
Code: Select all
<html><head><title>cset3300 hw5</title></head><body>
<h3> This is the Home Page, for the search page (part 3), please use the link below.</h3>
<a href = "search.php">Search Page</a>
<?php
//connect to database
mysql_connect("localhost","dfuller3","dfuller37318");
//specify database
mysql_select_db("dfuller3") or die("Unable to select database");
// Build SQL Query
$query = "select address_book.first_name,address_book.last_name,address.street, address.city, address.state,
address.zip_code
from address, address_book where address.address_book_id = address_book.id
AND address.address_type = 'home'
order by first_name ASC";
$result = mysql_query($query) or die(mysql_error());
$fields_num = mysql_num_fields($result);
echo "<h1>Table:People and Places</h1>";
echo "<table border='1'><tr>";
// printing table headers
for($i=0; $i<$fields_num; $i++)
{
$field = mysql_fetch_field($result);
echo "<td>{$field->name}</td>";
}
echo "</tr>\n";
//printing table rows
while($row = mysql_fetch_row($result))
{
echo "<tr>";
// $row is array... foreach( .. ) puts every element
// of $row to $cell variable
foreach($row as $cell)
echo "<td><a href=\"user_info.php\">$cell</a></td>";
echo "</tr>\n";
}
mysql_free_result($result);
?>
</body></html>