目前,我可以使用下拉列表来检索表格中显示的数据。我想让表格的每一行都可以点击。一旦我点击了该特定行,我希望该行的数据(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);
?>
答案 0 :(得分:0)
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'; */ }); });