php mysql动态表显示与numbring

php mysql动态表显示与numbring,php,javascript,mysql,Php,Javascript,Mysql,我有一个使用php从mysql填充表的页面。我有10张桌子。 如果表中没有数据,则不显示该表 $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

我有一个使用php从mysql填充表的页面。我有10张桌子。 如果表中没有数据,则不显示该表

$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;">&euro; <?php echo $price; ?></td></tr>
    <?php 
              }
    ?>
  </tbody>
我已经为表1显示了类似“1”的编号,为表2显示了类似“2”的编号,以此类推。现在,如果表3、6、9没有数据,页面将显示数字表1、2、4、5、7、8、10。但我想根据显示的表格数量来确定

$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;">&euro; <?php echo $price; ?></td></tr>
    <?php 
              }
    ?>
  </tbody>
$tbl2=“从wp\u health\u aanvullend\u模块中选择*,其中health\u id=$hid”;
$rs2=mysql\u查询($tbl2);
$count2=mysql\u num\u行($rs2);
阿恩瓦伦德模块

您应该在显示表的循环中使用计数器。在所有没有内容的表中,计数器都不会增加。

尝试以下方法:

$k=1;
for($i=1;$i<=10;$i++)
{
$query="select * from table".$i."";
$result=mysql_query($result);
$count=mysql_num_rows($result);
if($count>0)
{
echo"<table>";
echo"<tr><td>Table".$k."</td></tr>";
echo"</table>
$k++;
}

}
$k=1;
对于($i=1;$i0)
{
回声“;
回显“表”。$k.”;
回声“
$k++;
}
}

它的700行代码。我如何在这里粘贴。chekc iti在每个表“.table\u front”上都有类,并使用$(“.table\u front”).length()来计算表的数量。但是如何动态地使表麻木呢?