seany02 Posted April 26, 2009 Share Posted April 26, 2009 What im trying to do is to bring up all of the entries by a specific where clause. this is fine for 1 return for the type of table output im using. However the table only shows the first result. (im not getting any errors on screen to help either) i dont want to sacrifice the look of the table by changing the type of table, which i know works, which proves theres no issue with the sql (obviously you cant see the css formating either) as always any help is appreciated, especially since this is a very important part of the assignment <?php $name=$_POST["secondtxt"]; $db = @mysql_connect("localhost","root",""); if (!$db) { do_error("Could not connect to the server"); } // Connect to the database @mysql_select_db("Rufus" ,$db)or do_error("Could not connect to the database"); // Run query $result = mysql_query("SELECT * FROM project WHERE user_id='$name' ORDER BY project_id",$db); if ($myrow = mysql_fetch_array($result)) { echo "</b><br><b>Project ID: </b>"; echo $myrow['project_id']; echo "</b><br><b>Project Name:</b> <i>"; echo $myrow['project_name']; echo "</b><br><b>Client ID: </b>"; echo $myrow['client_id']; echo "</b><br><b>Deadline: </b>"; echo $myrow['project_deadline']; echo "</i><hr><br><b>Project Description</b><br>"; echo $myrow['project_description']; echo "<br><br> <B>Project Requirements</b><br> "; echo $myrow['project_requirements']; echo "<br><br><a href=\"javascript:self.history.back();\"><-- Go Back</a>"; } ?> </div> </div> <?php Quote Link to comment https://forums.phpfreaks.com/topic/155725-solved-loop-table-to-show-more-results-or-something-along-those-lines/ Share on other sites More sharing options...
mikesta707 Posted April 26, 2009 Share Posted April 26, 2009 change if ($myrow = mysql_fetch_array($result)) to while ($myrow = mysql_fetch_array($result)) using an if statement will only provide 1 result because the if statement is only executed once, where the while statement is executed until the condition is false (in this case the condition would become false when there are no more entries from your mysql result) hope that helps! Quote Link to comment https://forums.phpfreaks.com/topic/155725-solved-loop-table-to-show-more-results-or-something-along-those-lines/#findComment-819670 Share on other sites More sharing options...
seany02 Posted April 26, 2009 Author Share Posted April 26, 2009 You have no idea how much of a hero you are to me! Quote Link to comment https://forums.phpfreaks.com/topic/155725-solved-loop-table-to-show-more-results-or-something-along-those-lines/#findComment-819685 Share on other sites More sharing options...
mikesta707 Posted April 26, 2009 Share Posted April 26, 2009 haha no problem. Dont forget to mark this post as solved! Quote Link to comment https://forums.phpfreaks.com/topic/155725-solved-loop-table-to-show-more-results-or-something-along-those-lines/#findComment-819692 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.