savagenoob Posted March 27, 2009 Share Posted March 27, 2009 My script is not displaying the array like its supposed to. Doing a print_r shows all the data so I know the info is there, maybe someone can spot my error... <?php $select = "SELECT * FROM pq_crtp_quiz WHERE testname = '$testname' ORDER BY RAND() DESC LIMIT 1"; $query = mysql_query($select); echo mysql_error(); echo $select; $row[] = mysql_fetch_assoc($query); print_r($row); ?> <table> <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post" name="questionans"> <tr><td>Question #<?php echo $i;?></td></tr> <tr><td><?php echo $row['question'];?></td></tr> <tr><td>Option 1 <?php echo $row['option1']; ?><input name="option1" type="checkbox" value="option1" /></td></tr> <tr><td>Option 2 <?php echo $row['option2']; ?><input name="option2" type="checkbox" value="option2" /></td></tr> <tr><td>Option 3 <?php echo $row['option3']; ?><input name="option3" type="checkbox" value="option3" /></td></tr> <tr><td>Option 4 <?php echo $row['option4']; ?><input name="option4" type="checkbox" value="option4" /></td></tr> <tr><td><input type="submit" name="next" value="Next"></td></tr> </form> </table> Link to comment https://forums.phpfreaks.com/topic/151334-solved-database-array-not-displaying/ Share on other sites More sharing options...
ratcateme Posted March 27, 2009 Share Posted March 27, 2009 try changing $row[] to just $row you are adding the data to $row[0] so there is two keys you need to use. if you look closer at the print_r you will see a [0] => at the top Scott. Link to comment https://forums.phpfreaks.com/topic/151334-solved-database-array-not-displaying/#findComment-794877 Share on other sites More sharing options...
savagenoob Posted March 27, 2009 Author Share Posted March 27, 2009 Man, You are right, it works, thank you very much... SOLVED! Link to comment https://forums.phpfreaks.com/topic/151334-solved-database-array-not-displaying/#findComment-794878 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.