scmeeker Posted July 13, 2010 Share Posted July 13, 2010 I want to list the contents of my table but I don't want it to keep repeating and I'm trying to stop the loop but seem to be missing something that perhaps a more experienced set of eyes can catch. When I try, it will only show one record and stop but I want it to list them all and stop. Any suggestions? Thanks. Here is the code: $get_items_sql = "SELECT id, title, location, deadline, brief_description, date FROM list WHERE MONTH(date) = MONTH(CURDATE())"; $get_items_res = mysqli_query($mysqli, $get_items_sql) or die(mysqli_error($mysqli)); if (mysqli_num_rows($get_items_res) < 1) { $content = "<p><em>Sorry, no items in this category.</em></p>\n"; } else { $content .= "<ul>\n"; while ($items = mysqli_fetch_array($get_items_res)) { $item_url = "list_detail.php?id={$items['id']}"; $item_title = stripslashes($items['title']); $item_location = $items['location']; $item_deadline = $item_info['deadline']; $item_brief_description = $items['brief_description']; $item_id = $items['id']; $content .= ""; $content .="<table width=\"693\ height=\"300\" border=\"0\"><tr><td width=\"200\"> <a href=\"{$item_url}\"> {$item_title}</a><td width=\"251\">{$item_location}</td> <td width=\"109\">{$item_deadline}</td></tr><tr><td colspan=\"3\" valign=\"top\" class=\"blackfont\">{$item_brief_description}</td></tr></table>"; $content .= "\n"; } $content .= "</ul>\n"; Quote Link to comment https://forums.phpfreaks.com/topic/207641-stop-looping/ Share on other sites More sharing options...
khr2003 Posted July 14, 2010 Share Posted July 14, 2010 There is a missing curly bracket at the end of your code, aside from that you code looks fine. Are you receiving any errors when you run the code? Quote Link to comment https://forums.phpfreaks.com/topic/207641-stop-looping/#findComment-1085646 Share on other sites More sharing options...
Pikachu2000 Posted July 14, 2010 Share Posted July 14, 2010 If you have phpMyAdmin, paste your query in to it and see what results are returned. Unrelated, but you're missing a closing quote here: <table width=\"693\ height . . . Quote Link to comment https://forums.phpfreaks.com/topic/207641-stop-looping/#findComment-1085663 Share on other sites More sharing options...
scmeeker Posted July 14, 2010 Author Share Posted July 14, 2010 I fixed it. Thanks. In code that was just above the code that's shown (the next line above), there was a curly bracket that needed to be switched from open to closed and one had to be removed from the bottom. Thanks Pikachu for noticing my missing quote too. Got it fixed. It's a lot of stress on the brain learning PHP! I appreciate all your help you've given me. Quote Link to comment https://forums.phpfreaks.com/topic/207641-stop-looping/#findComment-1085911 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.