gpt4 book ai didi

php - 在 php 中发送和获取变量值

转载 作者:行者123 更新时间:2023-11-30 21:58:27 26 4
gpt4 key购买 nike

我正在从 ride MySQL 表中获取所有游乐设施并将其显示在 html 表中。

<?php
$db_host = 'localhost'; // Server Name
$db_user = 'root'; // Username
$db_pass = ''; // Password
$db_name = 'pz'; // Database Name

$conn = mysqli_connect($db_host, $db_user, $db_pass, $db_name);
if (!$conn) {
die ('Failed to connect to MySQL: ' . mysqli_connect_error());
}

$sql = 'SELECT *
FROM ride';

$query = mysqli_query($conn, $sql);

if (!$query) {
die ('SQL Error: ' . mysqli_error($conn));
}
?>
<table class="data-table">

<thead>
<tr>
<th>Car Number</th>
<th>From</th>
<th>To</th>
<th>DATE</th>
<th>Car Name</th>
<th>Take This Ride</th>
</tr>
</thead>
<tbody>
<?php

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

echo '<tr>
<td>'.$row['car_number'].'</td>
<td>'.$row['polazak'].'</td>
<td>'.$row['odrediste'].'</td>
<td>'. date('F d, Y', strtotime($row['datum'])) . '</td>
<td>'.$row['car_name'].'</td>
<td><a href="ridedetail.php?car_number= $car_number&polazak=$polazak"><button type="button">Take This Ride</button></a></td>
</tr>';

}?>
</tbody>
<tfoot>

</tfoot>
</table>

现在如果用户单击特定行,我想将该特定行的值带到下一页并显示在该页上。
谢谢。

最佳答案

试着把<a>之前 <tr>

<?php
$db_host = 'localhost'; // Server Name
$db_user = 'root'; // Username
$db_pass = ''; // Password
$db_name = 'pz'; // Database Name

$conn = mysqli_connect($db_host, $db_user, $db_pass, $db_name);
if (!$conn) {
die ('Failed to connect to MySQL: ' . mysqli_connect_error());
}

$sql = 'SELECT *
FROM ride';

$query = mysqli_query($conn, $sql);

if (!$query) {
die ('SQL Error: ' . mysqli_error($conn));
}
?>
<table class="data-table">

<thead>
<tr>
<th>Car Number</th>
<th>From</th>
<th>To</th>
<th>DATE</th>
<th>Car Name</th>
<th>Take This Ride</th>
</tr>
</thead>
<tbody>
<?php

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

echo '<a href="ridedetail.php?car_number='. $row['car_number'].'&polazak='.$row['polazak'].'">
<tr>
<td>'.$row['car_number'].'</td>
<td>'.$row['polazak'].'</td>
<td>'.$row['odrediste'].'</td>
<td>'. date('F d, Y', strtotime($row['datum'])) . '</td>
<td>'.$row['car_name'].'</td>
<td><a href="ridedetail.php?car_number='. $roe['car_number'].'&polazak='.$row['polazak'].'"><button type="button">Take This Ride</button></a></td>
</tr></a>';

}?>
</tbody>
<tfoot>

</tfoot>
</table>

关于php - 在 php 中发送和获取变量值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44267779/

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