i have page where i populate table from mysql using php. I have 10 tables.
If there is no data in table then the table is not displayed.
i have displayed numbering like “1” for table one 2 for table 2 and so on . now if table 3,6,9 have no data then page will display table of numbers 1,2,4,5,7,8,10. but i want that numbring according to the number of tables displayed.
$tbl2= "SELECT * FROM wp_health_aanvullend_moduliar WHERE health_id=$hid";
$rs2 = mysql_query($tbl2);
$count2 = mysql_num_rows($rs2);
<?php if($count2 > 0){?>
<table class="sub_front_efect" cellpadding="0" cellspacing="0" style=" border:none; margin:10px 0;">
<thead>
<tr>
<th colspan="100%" class="health_sub_front">Aanvullend moduliar</th></tr>
</thead>
<tbody>
<?php $wp_health_aanvullend_moduliar = "wp_health_aanvullend_moduliar";
$crows = $wpdb->get_results( "SELECT * FROM $wp_health_aanvullend_moduliar WHERE health_id=$hid");
foreach ($crows as $crow) {
$type = $crow->type ;
$price = $crow->price;
?>
<tr data-price="<?php echo $price; ?>"><td width="65%"><?php echo $type; ?></td><td style="border-right:1px solid #ccc;">€ <?php echo $price; ?></td></tr>
<?php
}
?>
</tbody>
<?php } ?>
if all the table has data then all displayed.
what can be the logic
thanks
You should use a counter inside the loop where you displaying the tables. In all tables without content the counter wouldn’t be increase.