This is an example I have grabbed from W3School, and for the purpose of my question, I have modified it and put in the code here:
<?php
// Make a MySQL Connection
mysql_connect("localhost", "admin", "1admin") or die(mysql_error());
mysql_select_db("test") or die(mysql_error());
// Get all the data from the "example" table
$result = mysql_query("SELECT * FROM example")
or die(mysql_error());
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
echo $row['name'] . " " . $row['age'] . "<br />";
}
?>
Does anyone know how I can print out the row number of each entry here. Say, if the mysql_num_rows() of the query is 3, then it would print something out like
1 David 24
2 Sam 25
3 Seth 20
How can I do that?
Thanks for your help.