Searching a database column (mySQL)

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
jc_ply
Forum Newbie
Posts: 5
Joined: Wed Mar 19, 2008 11:38 pm

Searching a database column (mySQL)

Post by jc_ply »

Hey I'm new to the forums and have just begun getting to grips with PHP to enhance my flash work. Anyway spent the last 2 weeks tackling it and im to the point where I'm a little confused on which way to go.

Basically i have a table which looks like this

id | name | img1 | img2 | img3 |

1 dave 3 5 3


the 3 5 3 are integers which will stand for image ids selected by the user and i need to find the most popular id and return the value via an integer to be picked up by flash (loadVars). So I need to search a column e.g "num1" find the most popular id and add up how many instances there are of it. My initial thoughts were towards arrays and loops but not too sure if im missing something being new to server side scripts.

I know I should probably separate the images and use a relational database but time is short, and my coding abilities are not too hot at the moment. I'd appreciate any help and hope to become more involved on the forum in the future.

Thanks,

Jason
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Searching a database column (mySQL)

Post by Christopher »

MySQL has some statistical functions:

http://dev.mysql.com/doc/refman/5.1/en/ ... tions.html
(#10850)
jc_ply
Forum Newbie
Posts: 5
Joined: Wed Mar 19, 2008 11:38 pm

Re: Searching a database column (mySQL)

Post by jc_ply »

thanks that literature pointed me in the right direction
Post Reply