Jump to content

Problem with PHP/SQL Select where


Walshie

Recommended Posts

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

 

Link to comment
https://forums.phpfreaks.com/topic/277932-problem-with-phpsql-select-where/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.