Web Analytics Made Easy -
StatCounter display 1-100, if a number is in the database display it red - CodingForum

Announcement

Collapse
No announcement yet.

display 1-100, if a number is in the database display it red

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • display 1-100, if a number is in the database display it red

    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?

  • #2
    1) fetch all results from database, get results into an array ($var).
    2) create a for loop
    PHP Code:
    for($i=1;$i<=100;$i++){} 
    3) use if statements or the switch method in combination with the in_array() 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.

    Comment

    Working...
    X
    😀
    🥰
    🤢
    😎
    😡
    👍
    👎