gpt4 book ai didi

php - 单击表格行以在新的 php 页面中显示所选行的数据

转载 作者:行者123 更新时间:2023-11-30 00:11:45 25 4
gpt4 key购买 nike

目前,我可以使用下拉列表来检索表格上显示的数据。我想让表格的每一行都可点击。单击该特定行后,我希望该行的数据(id、年龄、州、城市、医疗保健、团队、原因、计划日期、起始日期和 AAA_diam)显示在新的 php 页面中。它应该看起来像这样,我希望我说得足够清楚。

单击表格的一行后,将在新的 PHP 页面中显示信息。

Id: $id (from the table row)
age: $age
city: $city
healthcare: $healthcare
team: $team
cause: $cause
planned date: $planned date
from: $from
AAA_diam: $AAA_diam


<html>
<head>
<script type="text/javascript" src="script.js"></script>

</head>
<body>

<form name="Select_filter3" method="POST" action="index.php">

<select id="dropdown3" name="filter3">
<option value=""></option>
<option value="1">Amount of present</option>
<option value="2">Amount of absent</option>
<option value="3">Amount of present: destination</option>
<option value="4">Antal of absent: destination</option>
<option value="5">Amount A_diam > 3cm</option>
<option value="6">Amount A_diam > 5cm</option>
</select>



<input id="search_box2" type="text" name="search_box3" value="" />
<input id="submit2" type ="submit" name ="search3" value ="Ok">

</body>
</html>


<?php

include "connection1.php";

mysql_query ('SET NAMES UTF8;');
mysql_query ('SET COLLATION_CONNECTION=utf8_general_ci;');
mysql_client_encoding($connect);// where $conn is your connection





if (isset($_POST['search3'])) {

switch($_POST['filter3']) {

Default:
$sql = " ";
break;

case 1:
$sql = "SELECT * FROM mytable WHERE age = '35' AND city != 'Los Angeles' ";


echo "<table border='1'>
<tr>
<th>ID</th>
<th>age</th>
<th>state</th>
<th>city</th>
<th>healthcare</th>
<th>Team</th>
<th>cause</th>
<th>Planned date</th>
<th>From</th>
<th>diameter</th>
</tr>";

$query = mysql_query($sql) or die(mysql_error());

while($row = mysql_fetch_array($query)) {

echo "<tr>";
echo "<td>" . $row['id'] . "</td>";
echo "<td>" . $row['age'] . "</td>";
echo "<td>" . $row['state'] . "</td>";
echo "<td>" . $row['city'] . "</td>";
echo "<td>" . $row['healthcare'] . "</td>";
echo "<td>" . $row['Team'] . "</td>";
echo "<td>" . $row['cause'] . "</td>";
echo "<td>" . $row[’planned date’] . "</td>";
echo "<td>" . $row['from'] . "</td>";
echo "<td>" . $row['AAA_diam'] . "</td>";
echo "</tr>";
}

echo "</table>";
break;

mysql_close($connect);
?>

最佳答案

you can handle the click event of row using jQuery like$(document).ready(function(){    $("#your_table_id").delegate("tr.rows", "click", function(){       /*find the clicked row id column and redirect to user for that record         some thing like this http://www.yoursite.com/showrecord.php?id=5         using location.href='http://www.yoursite.com/showrecord.php?id=5';        */    });}); 

关于php - 单击表格行以在新的 php 页面中显示所选行的数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23985469/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com