我在表格中顯示聲明,我想讓每一行都可以點擊,這有點像我用 js onclick 函數所做的(我只能點擊名稱,但我想將它應用到整行)?,F在我想在新選項卡中查看有關公告的詳細信息。我的問題從這里開始。我想在單擊一行時獲得公告 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 關注
- 122 瀏覽
添加回答
舉報
0/150
提交
取消