我在表格中显示声明,我想让每一行都可以点击,这有点像我用 js onclick 函数所做的(我只能点击名称,但我想将它应用到整行)。现在我想在新选项卡中查看有关公告的详细信息。我的问题从这里开始。我想在单击一行时获得公告 ID,但不知道该怎么做。另外,我正在使用 js 进行 onclick,其余部分是 php,因此那里变得有点混乱。我知道这不是最好的方法,所以我需要你关于如何解决这个问题的建议。PS我对js不是很熟悉,那些js部分取自网络教程。下面的代码是我显示搜索结果的部分。<section id="results"> <div class="container"> <table> <tr> <a href="#"><th>Name</th></a> <th>Where</th> <th>From</th> <th>Date</th> <th>Price</th> <th>Type</th> <th>PId</th> </tr> <?php if(isset($_POST['search_btn'])){ include_once "db_connect.php"; $from = $_POST['from']; $where = $_POST['where']; $date = $_POST['date']; $type = $_POST['type']; $procid = $_POST['proc_id']; if(empty($from) || empty($where) || empty($date) || empty($type)){ header("Location: index.php?search=empty"); exit(); }else{ $sql = "SELECT * FROM proc WHERE p_from = '".$from."' and p_where = '".$where."' and type= '".$type."' "; $query = mysqli_query($conn, $sql); $num_rows = mysqli_num_rows($query); while ($rows = mysqli_fetch_array($query, MYSQLI_ASSOC)) { echo "<tr><td onclick='content(this)'>" . $rows['p_name'] . " " . $rows['p_surname']. " </td><td>" .$rows['p_from']. "</td><td>" .$rows['p_where']. "</td><td>" .$rows['p_date']. "</td><td>" .$rows['price']. "</td><td>" .$rows['type']. "</td></tr>" ; } echo "</table>"; } }else{ echo "Error!"; } ?>
- 3 回答
- 0 关注
- 114 浏览
添加回答
举报
0/150
提交
取消