PHP IF statement not taking variable into account!

Posted by Jess on Stack Overflow See other posts from Stack Overflow or by Jess
Published on 2010-03-19T12:51:07Z Indexed on 2010/03/19 13:01 UTC
Read the original article Hit count: 154

Filed under:
|
|

I have a tabled view in a while loop, where a user can view information on books.

For example, book ISBN, book name, read status...

Basically, when the user sets their 'readstatus' to 'complete' I want that specific table row to become grey! The logic is very straight forward, however I can't get my IF statement to recognise this:

$readstatus = $_GET['readstatus'];

if ($readstatus == 'complete') {
                        echo '<tr class="completed">';
              }

                    else if  ($readstatus != 'complete') {
                        echo '<tr class="reading">';
              } 

I'm obviously doing something wrong here, but all I need is the CSS class of the table row to change if the value of 'readstatus' = 'complete', if not, then output the default CSS table row color ('reading')

Should I be putting $result as the variable or something? I have this coming just before my nested IF statement:

$result = mysql_query($sql, $connection)
                or die ("Couldn't perform query $sql <br />".mysql_error());

              while($row = mysql_fetch_array($result))
        { ?>

© Stack Overflow or respective owner

Related posts about php

Related posts about if