Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jun 2011
    Thanked 0 Times in 0 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
    New Coder
    Join Date
    Jan 2010
    Birmingham, MI
    Thanked 9 Times in 9 Posts
    1) fetch all results from database, get results into an array ($var).
    2) create a for loop
    PHP Code:
    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.


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts