neo0506 Posted February 20, 2007 Share Posted February 20, 2007 I am trying to view ALL of the records in my rows onto a page. For some reason, it won't display them... Please help! this is the coding I have done: ?php require('./inc/function.php'); //require('./test/test14.php'); getRequestVariables(); if(!connectDB()) // Connect to 'qdbase' database { die("Could not connect: ".mysql_error()); // error if not connected to the database } if(!isset($recordi)) $recordi = 0; $result = mysql_query("select * from topic_content") or die("Select topic_content error! : ".mysql_error()); $rows = mysql_fetch_all($result); ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <?php foreach ($rows as $rowindex => $rows) { //display echo "$question"; echo " "; if($qutypes == "2") buttonShow($qutypes); echo " "; if(!empty($choice1)) buttonShow($qutypes); if(!empty($choice1)) echo "$choice1"; echo " "; if(!empty($choice2)) buttonShow($qutypes); if(!empty($choice2)) echo "$choice2"; echo " "; if(!empty($choice3)) buttonShow($qutypes); if(!empty($choice3)) echo "$choice3"; echo " "; if(!empty($choice4)) buttonShow($qutypes); if(!empty($choice4)) echo "$choice4"; echo " "; if(!empty($choice5)) buttonShow($qutypes); if(!empty($choice5)) echo "$choice5"; echo " "; if(!empty($choice6)) buttonShow($qutypes); if(!empty($choice6)) echo "$choice6"; echo " "; } ?> Link to comment https://forums.phpfreaks.com/topic/39324-i-cant-see-my-records-please-help/ Share on other sites More sharing options...
monk.e.boy Posted February 20, 2007 Share Posted February 20, 2007 foreach ($rows as $rowindex => $rows) can you do this? Two variables called $rows? Try renaming the second one.... monk.e.boy Link to comment https://forums.phpfreaks.com/topic/39324-i-cant-see-my-records-please-help/#findComment-189642 Share on other sites More sharing options...
skali Posted February 20, 2007 Share Posted February 20, 2007 $result = mysql_query("select * from topic_content") or die("Select topic_content error! : ".mysql_error()); while($row = mysql_fetch_array($result)){ //now $row in an array with table row echo $row['content_field1']; echo $row['content_field2']; echo $row['content_field3']; //and so on } Link to comment https://forums.phpfreaks.com/topic/39324-i-cant-see-my-records-please-help/#findComment-189654 Share on other sites More sharing options...
neo0506 Posted February 20, 2007 Author Share Posted February 20, 2007 skali, your solution only just displays the DATA...the thing is, im try to display the questions with the designated buttons i.e (radio buttons and multiple) The thing is when I use 'MY' code, it just shows a blank page and not the questions or buttons......not even an error message! Thanks tho! Link to comment https://forums.phpfreaks.com/topic/39324-i-cant-see-my-records-please-help/#findComment-189806 Share on other sites More sharing options...
neo0506 Posted February 20, 2007 Author Share Posted February 20, 2007 Hope this helps! Like I said, the code, when run only just gives me an empty screen! I need it to display ALL of my records from the table topic_content. Hope someone can help, been stuck on this for ages! [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/39324-i-cant-see-my-records-please-help/#findComment-189830 Share on other sites More sharing options...
Jessica Posted February 20, 2007 Share Posted February 20, 2007 add this to the top of the page: ini_set('display_errors', 1); error_reporting(E_ALL); Link to comment https://forums.phpfreaks.com/topic/39324-i-cant-see-my-records-please-help/#findComment-189832 Share on other sites More sharing options...
neo0506 Posted February 20, 2007 Author Share Posted February 20, 2007 showed me all of the problems with the code, trying to fix it....still need help tho! lol Link to comment https://forums.phpfreaks.com/topic/39324-i-cant-see-my-records-please-help/#findComment-189840 Share on other sites More sharing options...
Jessica Posted February 20, 2007 Share Posted February 20, 2007 Well if you post those errors and the lines of code they refer to, we can help. Link to comment https://forums.phpfreaks.com/topic/39324-i-cant-see-my-records-please-help/#findComment-189844 Share on other sites More sharing options...
neo0506 Posted February 20, 2007 Author Share Posted February 20, 2007 Oh ok! here is the code anyway...hopefully, this helps! Notice: Undefined variable: question in C:\Program Files\Apache Group\Apache2\htdocs\generator\gen.php on line 43 Notice: Undefined variable: qutypes in C:\Program Files\Apache Group\Apache2\htdocs\generator\gen.php on line 45 line 43 = echo "$question"; line 45 = if($qutypes == "2") buttonShow($qutypes); This problem, I bet is a small problem, and you guys are probably laughing at me...lol Thanks in advance! Link to comment https://forums.phpfreaks.com/topic/39324-i-cant-see-my-records-please-help/#findComment-189847 Share on other sites More sharing options...
Jessica Posted February 20, 2007 Share Posted February 20, 2007 Before trying to use a variable, you need to make sure it exists and is set. if(isset($question)){ echo $question; } Link to comment https://forums.phpfreaks.com/topic/39324-i-cant-see-my-records-please-help/#findComment-189859 Share on other sites More sharing options...
neo0506 Posted February 20, 2007 Author Share Posted February 20, 2007 jesirose, just read your 'how to ask a question page'...i broke some rules! copied the code you entered but I still get a blank page...this time no errors anymore. i think this is a complex problem... Link to comment https://forums.phpfreaks.com/topic/39324-i-cant-see-my-records-please-help/#findComment-189867 Share on other sites More sharing options...
monk.e.boy Posted February 21, 2007 Share Posted February 21, 2007 if(!empty($choice6)) buttonShow($qutypes); if(!empty($choice6)) echo "$choice6"; echo " "; So what does this line do? Why is there an empty echo? Post the code for buttonShow() monk.e.boy Link to comment https://forums.phpfreaks.com/topic/39324-i-cant-see-my-records-please-help/#findComment-190331 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.