Checking the database

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
Pezmc
Forum Commoner
Posts: 53
Joined: Mon Nov 06, 2006 2:15 pm

Checking the database

Post by Pezmc »

In my database I have lots of song names as below

Code: Select all

id   	 title   	 artist   	 album   	 submitter   	 submitterip   	 online   	 votes   	 code   	 sumbiteremail
1 	Don't Stop Me Now 	Queen 	The Complete Queen Collection 	Pez Cuckow 	192.168.0.3 	yes 	3 	  	 
2 	Eternal Clerking 	Amatatuer Transplants 	Fitness To Practice 	Pez Cuckow 	192.168.0.3 	yes 	1 	  	 
3 	Moments In Love (Quiet Storm) 	Art Of Noise 	Art of Noise 	Pez Cuckow 	192.168.0.3 	yes 	1 	  	 
4 	Moments In Love (Quiet Storm) 	Art Of Noise 	Art of Noise 	Pez Cuckow 	192.168.0.3 	yes 	1 	  	 
5 	You gotta Tap 	Audiobody 	Sound. Motion. Theater. 	Pez Cuckow 	192.168.0.3 	yes 	1 	  	 
6 	Sweet Harmony 	The Beloved 	Open Space 	Pez Cuckow 	192.168.0.3 	yes 	5
Sorry about misaligning,

On the home page I have these in order of votes and then run this statement to color code them;

Code: Select all

$numone = $num/100*20;
$numtwo = $num/100*40;
$numthree = $num/100*60;
And in the query

Code: Select all

if ($rank < "$numone") { $color = "bgcolor=\"#009900\""; } elseif ($rank > "$numone" && $rank < "$numtwo") {
$color = "bgcolor=\"#FF6600\""; } elseif ($rank > "$numtwo" && $rank < "$numthree") {
$color = "bgcolor=\"#CC3300\""; } elseif ($rank > "$numthree") {
$color = "bgcolor=\"#CC0000\""; }
$rank++;
I have now made a search box but would still like it to be color coded from the colors on this page, is there a way I can perform a mysql query to find my songs "rank" by votes and then color it using the thing above, so It makes if easier for my users to understand? Working example can be found here: http://labs.pezmc.com/radio/songlist.php
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Sorry, I don't understand your question. How is the rank computed?
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

Where does $num come from - is that the `votes` field from the db?
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply