Page 1 of 1

Checking the database

Posted: Thu Jan 25, 2007 2:17 am
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

Posted: Thu Jan 25, 2007 9:17 am
by feyd
Sorry, I don't understand your question. How is the rank computed?

Posted: Thu Jan 25, 2007 10:38 am
by pickle
Where does $num come from - is that the `votes` field from the db?