Walshie Posted May 12, 2013 Share Posted May 12, 2013 Hi All, I'm fairly new to php and after spending many hours searching forums i thought this would be the best place to post! I have a table, pt_roomcount with four fields, index, room, category, totcount When I run this SQL in PHPMYADMin I get the results I require (2 results - "Paints" and "Patio") ) "SELECT * FROM `pt_roomcount` WHERE `room`='Outdoors' group by `category`" But when I run it in PHP using the following I only get one results (Patio - the lata of the two) <?php $data = mysql_query("SELECT * FROM `pt_roomcount` WHERE `room`='Outdoors' group by `category` ") or die(mysql_error()); $info = mysql_fetch_array( $data ); while($info = mysql_fetch_array( $data )) { //This bit is irrelevant, its working fine Print "<li style='width:210px;'>"; Print "<a href='/shopping/".$info['room']."' style='padding:2px 0px 2px 0px;'>".$info['category']." (".$info['totcount'].")</a></li>"; } ?> Please can you advise? Thanks in advance! Chris Quote Link to comment https://forums.phpfreaks.com/topic/277932-problem-with-phpsql-select-where/ Share on other sites More sharing options...
Solution Jessica Posted May 12, 2013 Solution Share Posted May 12, 2013 You're calling the fetch function twice. The first time you never do anything with the result. Quote Link to comment https://forums.phpfreaks.com/topic/277932-problem-with-phpsql-select-where/#findComment-1429734 Share on other sites More sharing options...
Walshie Posted May 12, 2013 Author Share Posted May 12, 2013 Thanks Jessica - so simple when you know how! Solved Cheers Chris Quote Link to comment https://forums.phpfreaks.com/topic/277932-problem-with-phpsql-select-where/#findComment-1429739 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.