How do I echo an entire MySQL table with PHP? Right now I'm using the following code: <?php // Make a MySQL Connection mysql_connect("server", "login", "password") or die(mysql_error()); mysql_select_db("database") or die(mysql_error()); // Retrieve all the data from the "example" table $result = mysql_query("SELECT * FROM nfl_sch") or die(mysql_error()); // store the record of the "example" table into $row $row = mysql_fetch_array( $result ); // Print out the contents of the entry echo "week: ".$row['week']; echo " Home Team: ".$row['team_h']; echo " Away Team: ".$row['team_a']; echo " Game Time: ".$row['time']; echo " Home Team Votes: ".$row['v_team_h']; echo " Away Team Votes: ".$row['v_team_a']; ?> Code (markup): All I see is the first recode. There are about 5 and I want display all of them. Any help is much appreciated.
You have fetched only the first resulting row from mysql, but you need to fetch next rows too. See the manual for mysql_fetch_array, there is a simple example how to iterate through rows.