使用PHP创建动态表

时间:2014-12-06 15:00:52

标签: php mysqli dynamic html-table

我正在尝试使用PHP创建一个动态表,但我得到的是在我的表的每一列中,数组到达结尾,下一列从0开始到结束。

我试图把条件和做一些技巧来修复它,但我不能。 这是我得到以下代码的结果:

enter image description here

<?php
    $query_formsearch = mysqli_query($con,"SELECT * FROM `forms` ");
    $query_usr_prvlg = mysqli_query($con,"SELECT * FROM `profile` WHERE `id`='{$_SESSION["usr_id"]}' ");
    $usr_access=mysqli_fetch_assoc($query_usr_prvlg);
    $count=mysqli_num_rows($query_formsearch);
    $i=0;
?>

    <form action="" method="POST">
        <table>
            <tr>
                <th></th>
                <th></th>
                <th></th>
            </tr>
<?php   while($forms_row = mysqli_fetch_assoc($query_formsearch))
        {
            $f_num="form_".$forms_row['num']; 

?>
            <tr>
                <td>
                    <?php if(($usr_access[$f_num]=="1-1") || ($usr_access[$f_num]=="1-0")) ?>
                    <input  class='styled-input_m' type="hidden"  id="form-name" name ="form-name" value="<?php echo $forms_row['num']; ?>" />
                    <input  class='styled-input_m' type="submit"  id="sbmt-btn" name ="sbmt-btn" value="<?php echo $forms_row['name']; ?>" />
                </td>
                <td>
                    <?php if(($usr_access[$f_num]=="1-1") || ($usr_access[$f_num]=="1-0")) ?>
                    <input  class='styled-input_m' type="hidden"  id="form-name" name ="form-name" value="<?php echo $forms_row['num']; ?>" />
                    <input  class='styled-input_m' type="submit"  id="sbmt-btn" name ="sbmt-btn" value="<?php echo $forms_row['name']; ?>" />
                </td>
                <td>
                    <?php if(($usr_access[$f_num]=="1-1") || ($usr_access[$f_num]=="1-0")) ?>
                    <input  class='styled-input_m' type="hidden"  id="form-name" name ="form-name" value="<?php echo $forms_row['num']; ?>" />
                    <input  class='styled-input_m' type="submit"  id="sbmt-btn" name ="sbmt-btn" value="<?php echo $forms_row['name']; ?>" />
                </td>
            </tr>
<?php           

    }
?>
        </table>
    </form>

0 个答案:

没有答案