create a form from database contents
Posted: Sun Jan 22, 2012 9:29 pm
I am attempting to create a test in which the questions are contained in a database. I am retrieving the results of the query into an indexed array, but when I try to print them to the screen I get put into an infinite loop. My code is posted below:
include "dbconnect.php";
$SQLstring = "SELECT questiontext FROM test";
$QueryResult = "mysql_query($SQLstring, $con)";
echo "<form action=' ' method='post'>";
echo "<table width='100%' border = '1'>\n";
while(($Row = mysql_fetch_row($QueryResult)) !== FALSE)
{
echo "<tr><td>{$Row[0]}</td></tr>";
}
echo "</table>\n";
echo "</form>";
It seems to connect to the database but when looping through the array does not come to an end (it should pull 10 results from the database). Thank you for any help anyone can provide.
include "dbconnect.php";
$SQLstring = "SELECT questiontext FROM test";
$QueryResult = "mysql_query($SQLstring, $con)";
echo "<form action=' ' method='post'>";
echo "<table width='100%' border = '1'>\n";
while(($Row = mysql_fetch_row($QueryResult)) !== FALSE)
{
echo "<tr><td>{$Row[0]}</td></tr>";
}
echo "</table>\n";
echo "</form>";
It seems to connect to the database but when looping through the array does not come to an end (it should pull 10 results from the database). Thank you for any help anyone can provide.