Hello all,
I have a PHP table that populates from a MySQL database. I want to link each result in the table to their respective unique ID. The code below links each result to a unique ID, however the table now repeats the same name on every row.
Any ideas?
$result = mysql_query("SELECT concat(first_name, ' ', last_name), email, country, TimeStamp FROM {$table} order by {$sortkey} LIMIT
$id, {$records_per_page}") or
die(mysql_error());
$result_id = mysql_query("SELECT concat(first_name, ' ', last_name), email, country, TimeStamp, id FROM {$table} order by {$sortkey} desc LIMIT
$id, {$records_per_page}") or
die(mysql_error());
if (!$result) {
die("Query to show fields from table failed");
}
$fields_num = mysql_num_fields($result);
echo "<table id='tabledata' cellpadding='5'><tr>";
//Insert table headers
echo '<td><b><a href="'.$_SERVER['PHP_SELF'].'?sortkey='.(first_name).'">Name</a></b></td>';
echo '<td><b><a href="'.$_SERVER['PHP_SELF'].'?sortkey='.(email).'">E-Mail</a></b></td>';
echo '<td><b><a href="'.$_SERVER['PHP_SELF'].'?sortkey='.(country).'">Country</a></b></td>';
echo '<td><b><a href="'.$_SERVER['PHP_SELF'].'?sortkey='.(id).'">Date Created</a></b></td>';
echo "<tr>\n";
// Display the table rows
while($row = mysql_fetch_row($result))
while($row_id = mysql_fetch_row($result_id))
foreach($row as $cell)
echo "<td><a href=../ui/edit_customer.php&id=$row_id[4]>$cell</a></td>";
echo "</tr>\n";
}
mysql_free_result($result);