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
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>

<?

    }

?>

 

Link to comment
Share on other sites

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

 

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.