[PHP] Status for on and off with color.

Hi Guys,
I have a form and a table and at the moment I have a status column where the input is just text so "on" or "off" is put in.
I was hoping to make the table show a green or red circle for being on or off and use a radio button to select if it is on in the table. I have tried looking for this but havnt had any luck on the color side of the problem.
here is my code for the table:

// display data in table

echo "

"; echo ""; // loop through results of database query, displaying them in the table while($row = mysql_fetch_array( $result )) { // echo out the contents of each row into a table echo ""; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ""; } // close table> echo "
ID Administration Console Product Version Platform Database Owner Status
' . $row['id'] . ''.$row['curl'].'' . $row['pversion'] . '' . $row['platform'] . '' . $row['dversion'] . '' . $row['email'].'' . $row['status'] .'EditDelete



Thanks in Advance


  • The formating has messed up of the code and cant seem to edit it...

  • Hi Daniel,

    Set a class on your HTML display, you could even make it class="PG" for example in case you decide to change the color of it later. Then you define the color of that class in css for php development.

    Using the example code you provided:

    "> <?php echo $status;?>
    CSS file would include:

    .PG {text-color:green;}
    .PEN {text-color:red;}
    Note: not sure if by color you meant background-color or text-color; either works.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!