Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

PHP with MySQL

Name: Anonymous 2010-12-16 8:44

So... here is my code:

mysql_select_db("mydb");

$SQLstring = "SELECT FANID, NAME, CITY, EMAIL FROM FANS;";

$QueryResult = mysql_query($SQLstring)

     Or die("<P>Unable to execute the query</P>" .

          "<P>Error code " . mysql_errno($DBConnect) .

            " : " . mysql_error($DBConnect) . "</P>");

echo "<P>$QueryResult</P>";


What do I have to echo to get it to print out the entire table? (It's only 4 entries)

Name: Anonymous 2010-12-16 9:03

I got it... there is no magical command to print an entire table, I need to step through each row with a loop, and print the contents of that row, specifying each table element for the columns:


$Row = mysql_fetch_row($QueryResult);

echo "<TR><TD>FanID</TD><TD>Name</TD><TD>City</TD><TD>Email</TD></TR>";
do
{
  echo "<TR><TD>{$Row[0]}</TD><TD>{$Row[1]}</TD><TD>{$Row[2]}</TD><TD>{$Row[3]}</TD></TR>";
  $Row = mysql_fetch_row($QueryResult);
} while ($Row);

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List