Hide table if the sql query is empty

Hello

How I can hide table if the sql query is empty?

I tried this one

[php]<?php if(!empty($queryRC)) { ?>
//my table

<?php }else{} ?>

[/php]

i also tried this one

[php]<?php if($queryRC !="" ) { ?>
//my table

<?php }else{} ?>

[/php]

And both did not work for me

QJK,

Assuming $queryRC contains your result from the query, you can do this…

If you’re using mysqli

[php] <?php if (mysqli_num_rows($queryRC) > 0) { ?>
//my table

<?php } ?>[/php]

or this is you’re using the depreciated methods

[php] <?php if (mysql_num_rows($queryRC) > 0) { ?>
//my table

<?php } ?>[/php]

If you’re using PDO then you will use the fetchColumn method…

PDOStatement::fetchColumn

Sponsor our Newsletter | Privacy Policy | Terms of Service