holladb Posted November 15, 2007 Share Posted November 15, 2007 Hey anybody got a solution for this, im trying to display all of the "subcat01called" fields. I'm having no luck though... for ($i=1; $i<=1; $i++) { $handbags = ''; $accessories = ''; $jewelry = ''; $scarves = ''; $sql = "SELECT * FROM terms WHERE cereal=$i"; //print($sql . "<br>"); $result = $db->query($sql); $countem = '1'; while($row = $result->fetch()) { if ($i==1) { $handbags .= 'aI("text=' . $row['subcat01called'] . ';url=javascript:void(0);"); '; } } } Quote Link to comment https://forums.phpfreaks.com/topic/77526-cant-display-properly/ Share on other sites More sharing options...
Daniel0 Posted November 15, 2007 Share Posted November 15, 2007 What is the error? Also, why do you have that for loop? It will only do one iteration. Quote Link to comment https://forums.phpfreaks.com/topic/77526-cant-display-properly/#findComment-392441 Share on other sites More sharing options...
holladb Posted November 15, 2007 Author Share Posted November 15, 2007 there is no error, it only displays one result. Quote Link to comment https://forums.phpfreaks.com/topic/77526-cant-display-properly/#findComment-392443 Share on other sites More sharing options...
pocobueno1388 Posted November 15, 2007 Share Posted November 15, 2007 It should only display one result, because that is what your telling it to do with the for loop. Explain exactly what your trying to do. Quote Link to comment https://forums.phpfreaks.com/topic/77526-cant-display-properly/#findComment-392445 Share on other sites More sharing options...
Daniel0 Posted November 15, 2007 Share Posted November 15, 2007 Try running SELECT * FROM terms WHERE cereal=1; from the terminal or using some GUI tool (MySQL Query Browser, phpMyAdmin etc.). Does that return multiple rows? If no, then there is your answer. It should only display one result, because that is what your telling it to do with the for loop. Explain exactly what your trying to do. No it doesn't, the query could still return more than one row thus going through the while loop multiple times. Quote Link to comment https://forums.phpfreaks.com/topic/77526-cant-display-properly/#findComment-392447 Share on other sites More sharing options...
holladb Posted November 15, 2007 Author Share Posted November 15, 2007 another programmer started on this, im not sure why he put the loop in... the code is going into milonic menu....so each variable stands as a menu title if you will. the database query should grab all content for subcat01 and display it... as $handbags Quote Link to comment https://forums.phpfreaks.com/topic/77526-cant-display-properly/#findComment-392448 Share on other sites More sharing options...
holladb Posted November 15, 2007 Author Share Posted November 15, 2007 yes, the database is filled with 3 subcat01's Quote Link to comment https://forums.phpfreaks.com/topic/77526-cant-display-properly/#findComment-392450 Share on other sites More sharing options...
pocobueno1388 Posted November 15, 2007 Share Posted November 15, 2007 It should only display one result, because that is what your telling it to do with the for loop. Explain exactly what your trying to do. No it doesn't, the query could still return more than one row thus going through the while loop multiple times. Yes, but that is not what I meant. They had put $i in their query, and the for loop only runs once, so $i would only be equal to 1. I thought they were trying to change the query up for each iteration of the loop, but that wouldn't work since $i wouldn't change. I was thinking more along the lines of it only displaying one set of results. I worded that last post horribly. Quote Link to comment https://forums.phpfreaks.com/topic/77526-cant-display-properly/#findComment-392452 Share on other sites More sharing options...
holladb Posted November 15, 2007 Author Share Posted November 15, 2007 $i is populated in the loop... Quote Link to comment https://forums.phpfreaks.com/topic/77526-cant-display-properly/#findComment-392454 Share on other sites More sharing options...
Daniel0 Posted November 15, 2007 Share Posted November 15, 2007 $i is populated in the loop... Not in the code you posted. Quote Link to comment https://forums.phpfreaks.com/topic/77526-cant-display-properly/#findComment-392455 Share on other sites More sharing options...
holladb Posted November 15, 2007 Author Share Posted November 15, 2007 once it is completed $i will be populated with the loop. let's not lose track though, we're trying to get this to display all of the sql results Quote Link to comment https://forums.phpfreaks.com/topic/77526-cant-display-properly/#findComment-392457 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.