Jump to content

display table if variable is set


esoteric

Recommended Posts

Hi, i cant seem to get something working, should be simple but its not working for me.

 

I just need to only display a table if a variable in my table = a certain value.

 

The column in the table is called 'option1_available' and if its value is set to 'Y' i want it to display a table.

 

Appreciate any help, Thanks

Link to comment
https://forums.phpfreaks.com/topic/247303-display-table-if-variable-is-set/
Share on other sites

you just need to get that variable before you "draw" the table then you can just encase it in an if statement.

 

 

Example:

<?

    if($var)

    {

?>

        <table>

            <tr>

                <td></td>

                <td></td>

                <td></td>

            </tr>

        </table>

<?

    }

?>

 

I tried

 

$op1_av = ("SELECT option3_available FROM $tbl WHERE title='$product'") or die ("Cannot find purchase options");

if  ( $op1_av == 'Y' ) {

...

}else echo "Nope, not working :(";

 

but it just echo the else statement instead, even if the variable in the table is set to Y

 

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.