View Full Version : display 1-100, if a number is in the database display it red

08-21-2011, 05:49 AM
Need some help. I need to display numbers 1-100 and check to see if the numbers are in a database table, if so then turn the corresponding number red.

So if numbers 4,8,64, and 84 are in the database only those numbers would turn red in the numbers displayed on the page.

Any suggestions?

08-21-2011, 05:58 AM
1) fetch all results from database, get results into an array ($var).
2) create a for loop

3) use if statements or the switch method in combination with the in_array() (http://php.net/manual/en/function.in-array.php) function.

--> echo the HTML in both if statements. for the if(in_array($var)===TRUE){} statement, echo the HTML, but add a style attribute defining color as red.

This is a blueprint to how I would approach it.