MySQL Limit

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Qaid
Forum Commoner
Posts: 33
Joined: Wed Feb 15, 2006 12:04 pm

MySQL Limit

Post by Qaid »

Hi,

I have this code:

Code: Select all

$sql = mysql_query("SELECT * FROM table");


Inside this Mysql db I have multiple data, one row is called "category". In the category row I have different values, like 'Toys', 'Games' etc..

Is it possible to only get the row with data containing 'Games'? And how do i do it?

Thanks!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

can you post an export of the table's structure and some example records?
Qaid
Forum Commoner
Posts: 33
Joined: Wed Feb 15, 2006 12:04 pm

Post by Qaid »

Can't find out hte exporting stuff,

But i have these Tables: id, title, category, description and prize.

Some examples could be...
id - title - category - description - prize

1 Grape Fruit ... 2.99
2 Football Games ... 5.99
3 Apple Fruit ... 9.99

Etc, etc...

If is it possible to post only those containing Fruit from the category and sort them by id so number 1 come first?

Thanks againg..
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

Code: Select all

$sql = "SELECT * FROM `table` WHERE `category` = 'Fruit' ORDER BY `id` ASC";
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Qaid
Forum Commoner
Posts: 33
Joined: Wed Feb 15, 2006 12:04 pm

Post by Qaid »

Thank you guys very much :)
Post Reply