Jump to content

Problem with PHP/SQL Select where


Walshie
Go to solution Solved by Jessica,

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.