douyue4334 2016-06-02 10:26
浏览 38
已采纳

如何在PHP之后添加更多HTML?

I want to put the buttons right below the table, which I retrieve from database using PHP. But I don't know how to put the buttons below as they keep appearing above the table.


<html>
<body bgcolor="#E6E6FA"><center>
<h2>Existing Librarian System Access Profile</h2><br><br>
<?php
$hostid= 'localhost';
$user='root';
$pass='';
$db= 'projectdata';
$con = mysqli_connect($hostid, $user, $pass,$db);
mysqli_select_db($con,$db);


$query = "SELECT librarian_id, username, name, ic_no, phone_no, date_created, date_update FROM Librarian";
$run=mysqli_query($con, $query);
            $num_rows=mysqli_num_rows($run);

            if($run===FALSE){
                die(mysql_error());
            }

            if($num_rows>0)
            {
                echo "<table><tr><th>Librarian ID</th><th>Username</th><th>Name</th><th>National ID No</th><th>Phone No</th><th>Date Created</th><th>Date Update</th>";
                while ($row=mysqli_fetch_array($run))
                {   

                $librarian_id=$row['librarian_id'];
                $username=$row['username'];
                $name=$row['name'];
                $id_no=$row['ic_no'];
                $phone_no=$row['phone_no'];
                $date_created=$row['date_created'];
                $date_update=$row['date_update'];

                echo "<tr><td>$librarian_id</td><td>$username</td><td>$name</td><td>$id_no</td><td>$phone_no</td><td>$date_created</td><td>$date_update</td></tr>";
                }
            }?><input type="submit" name="add" value="Add Librarian"><input type="submit" name="delete" value="Delete Librarian"></center></body></html>
  • 写回答

4条回答 默认 最新

  • dongzhao4036 2016-06-02 10:37
    关注

    You can do like this:

    <html>
    <body bgcolor="#E6E6FA"><center>
    <h2>Existing Librarian System Access Profile</h2><br><br>
    <table>
    <tr><th>Librarian ID</th><th>Username</th><th>Name</th><th>National ID No</th><th>Phone No</th><th>Date Created</th><th>Date Update</th>
    
    
    
    
    <?php
    $hostid= 'localhost';
    $user='root';
    $pass='';
    $db= '';
    $con = mysqli_connect($hostid, $user, $pass,$db);
    mysqli_select_db($con,$db);
    
    
    $query = "SELECT librarian_id, username, name, ic_no, phone_no, date_created, date_update FROM Librarian";
    $run=mysqli_query($con, $query);
                $num_rows=mysqli_num_rows($run);
    
                if($run===FALSE){
                    die(mysql_error());
                }
    
                if($num_rows>0)
                {
    
                    while ($row=mysqli_fetch_array($run))
                    {   
    
                  $librarian_id=$row['librarian_id'];
                    $username=$row['username'];
                    $name=$row['name'];
                    $id_no=$row['ic_no'];
                    $phone_no=$row['phone_no'];
                    $date_created=$row['date_created'];
                    $date_update=$row['date_update'];
    ?>
    </tr>
    
    <tr> <td><?php echo $librarian_id;?></td><td><?php echo $username;?></td><td><?php echo $name;?></td><td><?php echo $id_no;?></td><td><?php echo $phone_no;?></td><td><?php echo $date_created;?></td><td><?php echo $date_update;?></td></tr>
    
    
                    <?php
                    }
                }?>
                </table>
                <input type="submit" name="add" value="Add Librarian"><input type="submit" name="delete" value="Delete Librarian"></center></body></html>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 一道python难题
  • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度