Hi there, first off I'm relatively new to php so please forgive me if this seems a simple request!

I have an existing database and menu system which works great, but I'm trying to modify it so that I have a checkbox that I can tick to determine if I want the result shown on the menu or not.

In mysql I've created a simple table where if the box is checked then "1" is shown.

The problem I have is asking php to echo the result "if" the box is checked, this is the code I have thus far (I know it's real messy!)

$query = mysql_query("SELECT * FROM employees WHERE flag = 's' ORDER BY time")
      or die(mysql_error());      
      while($row = mysql_fetch_array( $query )) {    

        {
        } 


 echo "<p class=\"text\">";
                echo "<img src=\"http://www.****.png\" width=\"20\" height=\"16\" align=\"absmiddle\"/>"; 
echo " ";
                echo $row['time'];      

echo " ";         
                echo $row['match'];

echo " ";
                if($row['match'])  echo "<a href=\"http://www.****/{$row['id']}.html\">Watch <img src=\"http://www.****/play.png\" align=\"absmiddle\"/></a>";  else echo "" ;
    echo "</p>";            

        }
      ?>

Now this is the existing code and as I said, it works, but when I try to insert and if arguement then an else I just get a syntax error

    $query = mysql_query("SELECT * FROM employees WHERE flag = 's' ORDER BY time")
          or die(mysql_error());      
          while($row = mysql_fetch_array( $query )) {    

            {
            } 

    if ($row['av'] == "1")
     echo "<p class=\"text\">";
                    echo "<img src=\"http://www.****.png\" width=\"20\" height=\"16\" align=\"absmiddle\"/>"; 
    echo " ";
                    echo $row['time'];      

    echo " ";         
                    echo $row['match'];

    echo " ";
                    if($row['match'])  echo "<a href=\"http://www.****/{$row['id']}.html\">Watch <img src=\"http://www.****/play.png\" align=\"absmiddle\"/></a>";  else echo "" ;
        echo "</p>";            
           else echo ""; 
            }
          ?>

any chance anyone can tell me where I'm going wrong?

Many thanks in advance!

An if statement needs to be in a block, seperated so that php knows how much of the following code is included in the condition:

if(condition is true) { doSomething; doMore(); doEvenMore();} butThisAlwaysHappens();

So your code would be something like this:

    $query = mysql_query("SELECT * FROM employees WHERE flag = 's' ORDER BY time")
    or die(mysql_error());
    while($row = mysql_fetch_array( $query )) {    
        if ($row['av'] == "1") {
            echo "<p class=\"text\">";
            echo "<img src=\"http://www.****.png\" width=\"20\" height=\"16\" align=\"absmiddle\"/>";
            echo " ";
            echo $row['time'];
            echo " ";
            echo $row['match'];
            echo " ";
            if($row['match']) echo "<a href=\"http://www.****/{$row['id']}.html\">Watch <img src=\"http://www.****/play.png\" align=\"absmiddle\"/></a>"; else echo "" ;
            echo "</p>";
        } else echo "";
    }   

In addition to adding braces for the if and else, I moved the condition inside the while loop so that it gets the chance to test all results instead of only the very last one.

Hope that helps!

thanks so much, will give this a shot

what you say makes sense to a php newbie :)