douliao8402 2014-12-06 15:00
浏览 36

使用PHP创建动态表

I'm trying to create a dynamic table using PHP but what I get is in each column of my table the array goes to the end and the next column is staring from the 0 to the end.

I tried to put if conditions and do some tricks to fix it but I couldn't. this is the result I get for below code :

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条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
    • ¥20 怎么用dlib库的算法识别小麦病虫害
    • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
    • ¥15 java写代码遇到问题,求帮助
    • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?