如何将数据库数据显示到另一页


How to display database data to another page?

这是我的房间表的代码

<?php
    include'db.php';
    $sql=mysql_query("Select*from tb_rooms1");
    echo "<div class='container'>";
    echo "<div class='scrolltable'>";
    echo "<table class= 'table table-striped table-bordered'>";
    echo"<th><div align='center'>ID</div></th>";
    echo"<th><div align='center'>Image</div></th>";
    echo"<th><div align='center'>Room Name</div></th>";
    echo"<th><div align='center'>Description</div></th>";
    echo"<th><div align='center'>Price Per Night</div></th>"; 
    echo"<th><div align='center'>Status</div></th>";
    echo"<th><div align='center'>Reserve</div></th>";
    while($row=mysql_fetch_array($sql))
    {
        @$id=$row['eid'];
        echo"<tr align='center'>";
        echo"<td><div style='font-size:11px;' align='center'>".$row['roomID']</div></td>";
        echo"<td><div style='font-size:11px;' align='center'><img width=72 height=52 alt='Unable to View' src=".$row['image']."></div></td>";
        echo"<td><div style='font-size:11px;' align='center'>".$row['name']."</div></td>";
        echo"<td><div style='font-size:11px;' align='center'>".$row['description']."</div></td>";
        echo"<td><div style='font-size:11px;' align='center'>".$row['price']."</div></td>";
        echo"<td><div style='font-size:11px;' align='center'>".$row['status']."</div></td>";
        echo"<td><div align='center' style='margin-top:30px'><input style='margin-top:-2px;' type='checkbox'></div></td>";
    }
    echo"</table>";
    echo"</div>";
    echo"</div>";
?>  

我不知道如何将所选房间的信息显示到另一个页面。有人可以帮助我吗? 我是

使您的房间可点击,并将房间 ID 作为参数传递

echo"<td><div style='font-size:11px;' align='center'><a href='otherpage.php?roomid={$row['roomID']}'> Room {$row['roomID']}</a></div></td>";

在你的另一个php文档中,你会有这样的东西:

otherpage.php
<?php
include'db.php';
$roomid = $_GET['roomid'];
$lookupQuery = mysqli_query("SELECT * FROM tb_rooms1 WHERE roomID = [$roomid]");

。根据需要显示数据

您需要研究的一件事是 mysql 注入,因为您的代码正在使用 mysql,并且参数直接传递到您的查询中......