Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: echo mysql data

  1. #1
    New Coder
    Join Date
    Nov 2011
    Posts
    74
    Thanks
    4
    Thanked 0 Times in 0 Posts

    echo mysql data

    I have 1 column named "style" in my db. In this column I use 2 values, "1" and "2". I wan't to SELECT * from db and echo rows that have value "1" in yellow background and rows that have value "2" in black background, all ORDER BY style DESC.
    What should I use?

    ty

  • #2
    Regular Coder
    Join Date
    Apr 2004
    Posts
    298
    Thanks
    0
    Thanked 23 Times in 23 Posts
    A good start is to show us what coding you have tried thus far

  • #3
    Regular Coder
    Join Date
    Jan 2012
    Posts
    271
    Thanks
    2
    Thanked 65 Times in 65 Posts
    in the table (i'm assuming you are displaying the recs in a table as you have given very little detail) add the following into the row

    PHP Code:
    background-color="<?php echo $thisStyle == 'yellow' 'black';?>"
    the variable $thisStyle needs to be replaced with whatever you have available in the loop that holds the value

  • #4
    New Coder
    Join Date
    Nov 2011
    Posts
    74
    Thanks
    4
    Thanked 0 Times in 0 Posts
    thank you jmj for the answear.
    And if I wan't to change more than the background... should I use SWITCH statement? Or what is the easiest way?

  • #5
    Regular Coder
    Join Date
    Jan 2012
    Posts
    271
    Thanks
    2
    Thanked 65 Times in 65 Posts
    if you wanted to change other parts of the styling depending on the result of either 2 options i'd suggest just use that same kind of statement for the different style options...


  •  

    Posting Permissions

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