I am using php for the first time and I am stuggling with something that is simple to most people. I am using mysql and php to select text from a database and display it in a html form but its not working, any ideas? Its supposed to be a one line quiz site where the user is presented with a question and 4 possible answers. The output that I am getting is just a blank interface the questions and answers are not coming from the database although I'm not getting any error message.
<?php session_start(); ?> <html> <head> <title>Successful login</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body bgcolor="#FFFFFF" text="#000000"> <?php $host="localhost"; $user="root"; $password=""; $database="Quizmaster"; $id=rand(0,5); $connection = mysql_connect($host,$user,$password) or die ("couldn't connect to server"); $db = mysql_select_db($database,$connection) or die ("Couldn't select database"); $query = "select * from questions where ID = '$id'"; $result = mysql_query($query); $row = mysql_fetch_array($result,MYSQL_ASSOC); while ($row = mysql_fetch_array ($result)) { extract($row); $_SESSION['id']=$id; $questext=$_POST["question"]; $ans1=$_POST["answer1"]; $ans2=$_POST["answer2"]; $ans3=$_POST["answer3"]; $ans4=$_POST["answer4"]; $_SESSION['correctans']=$correctans; } ?> <table width="68%" height="240"> <tr> <td width="14%" height="28"><font face="Arial, Helvetica, sans-serif"></font></td> <td colspan="2" height="28" bgcolor="#00CCFF"> <div align="center"> <? echo "$questext"; ?> </div> <div align="center"></div> <td width="0%"> </td> <div align="center"> <p><b><font face="Arial, Helvetica, sans-serif"> <textarea name="question" cols="70"></textarea> </font></b></p> <p><b><font face="Arial, Helvetica, sans-serif"></font></b></p> </div> <td width="11%"></td> </tr> <tr> <td width="14%" height="92"><font face="Arial, Helvetica, sans-serif"></font></td> <td width="38%" height="92" bgcolor="#999999"> <div align="center"> <p><b><font face="Arial, Helvetica, sans-serif"> <input type="radio" name="radiobutton" value="radiobutton"> <? echo "$ans1"; ?> </font></b></p> <p><b><font face="Arial, Helvetica, sans-serif"> </font></b></p> </div> </td> <td width="37%" bgcolor="#999999" height="92"> <div align="center"> <p><b><font face="Arial, Helvetica, sans-serif"> <input type="radio" name="radiobutton" value="radiobutton"> <? echo "$ans2";?> </font></b></p> <p><b><font face="Arial, Helvetica, sans-serif"> </font></b></p> </div> </td> </tr> <tr> <td width="14%" height="28"><font face="Arial, Helvetica, sans-serif"></font></td> <td width="38%" bgcolor="#999999"> <div align="center"><b><font face="Arial, Helvetica, sans-serif"> <input type="radio" name="radiobutton" value="radiobutton"> <? echo "$ans3"; ?> </font></b></div> <div align="center"></div> </td> <td width="37%" bgcolor="#999999"> <div align="center"> <p><b><font face="Arial, Helvetica, sans-serif"> <input type="radio" name="radiobutton" value="radiobutton"> <? echo "$ans4"; ?> </font></b></p> <p><b><font face="Arial, Helvetica, sans-serif"> </font></b></p> </div> </td> </tr> </table> </body> </html> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php