Forum Moderators: coopster
$query = "SELECT CONCAT(name, phone, fax) AS entries FROM suppliers ORDER BY name ASC";// Run the query.
$result = @mysql_query ($query);// If it ran OK, display the records.
if ($result) {
echo '<table width="100%"><tr><td>Total listings - '. $row_count . ':</td></tr>';// Fetch and print all the records.
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
echo "<tr><td>$row[0]</td></tr>\n";
}echo '</table>';
... and I would like the output to have each row numbered incrementally, irrespective of what order they're displayed in.
I've tried various things without success. Help would be appreciated.
Patrick
$query = "SELECT CONCAT(name, phone, fax) AS entries FROM suppliers ORDER BY name ASC";
// Run the query.
$result = @mysql_query ($query);
// If it ran OK, display the records.
if ($result) {
$rownum=1;//variable to keep track of row number
echo '<table width="100%"><tr><td>Total listings - '. $row_count . ':</td></tr>';
// Fetch and print all the records.
while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
echo "<tr><td>".$rownum++." $row[0]</td></tr>\n";
}/*use of post increment to go to the next row number after displaying the current one*/
echo '</table>';