gpt4 book ai didi

php - 获取错误解析错误 : syntax error, 意外 '$_GET' (T_VARIABLE)

转载 作者:太空宇宙 更新时间:2023-11-03 10:45:43 26 4
gpt4 key购买 nike

我正在制作一个页面,在第 1 页上,我从 mysql 获取数据,然后单击名称,我将重定向到另一个页面,即显示完整详细信息的第 2 页。请帮忙 !这是第 1 页的 php 代码

            $host="localhost"; // Host name 
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="testmra"; // Database name
// Connect to server and select databse.
$conn=mysqli_connect($host,$username,$password) or die("cannot connect");
mysqli_select_db($conn,$db_name);
$result = mysqli_query($conn,"SELECT name,COUNT(status_id) AS Count from bookingdetails WHERE YEAR(date) = YEAR(CURDATE()) AND MONTH(date) = MONTH(CURDATE()) AND status_id='2' GROUP BY name");
echo "<table border='1' style='border:black;'>
<tr>
<!--<th id='td'>Sr No.</th>-->
<th id='td'>Name</th>
<th id='td'>No. of Bookings Done</th>
</tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>";

echo "<td align='center' id='td'><a href='Details.php'>" . $row['name'] . "</a></td>";
echo "<td align='center' id='td'>" . $row['Count'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysqli_close($conn);
?>

Page 2
<?php

$host="localhost"; // Host name
$username="root"; // Mysql username
$password=""; // Mysql password
$db_name="testmra"; // Database name
// Connect to server and select databse.
$conn=mysqli_connect($host,$username,$password) or die("cannot connect");
mysqli_select_db($conn,$db_name);
$name=(varchar) $_GET['name'];
$result = mysqli_query($conn,"SELECT * from bookingdetails WHERE YEAR(date) = YEAR(CURDATE()) AND MONTH(date) = MONTH(CURDATE()) AND status_id='2' AND name='$name'");
echo "<table border='1' style='border:black;'>
<tr>
<th id='td'>Room</th>
<th id='td'>Name</th>
<th id='td'>Purpose</th>
<th id='td'>Attendee</th>
<th id='td'>Date</th>
<th id='td'>Start Time</th>
<th id='td'>End Time</th>
</tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>";

echo "<td align='center' id='td'>" . $row['room'] . "</td>";
echo "<td align='center' id='td'>" . $row['name'] . "</td>";
echo "<td align='center' id='td'>" . $row['purpose'] . "</td>";
echo "<td align='center' id='td'>" . $row['attendee'] . "</td>";
echo "<td align='center' id='td'>" . $row['date'] . "</td>";
echo "<td align='center' id='td'>" . $row['starttime'] . "</td>";
echo "<td align='center' id='td'>" . $row['endtime'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysqli_close($conn);
?>

最佳答案

更改 page1 中的以下行

 echo "<td align='center' id='td'><a href='Details.php'>" . $row['name'] . "</a></td>";

 echo "<td align='center' id='td'><a href='Details.php?name=" . $row['name'] . "'>" . $row['name'] . "</a></td>";

在第 2 页

(varchar) $_GET['name']

$_GET['name']

关于php - 获取错误解析错误 : syntax error, 意外 '$_GET' (T_VARIABLE),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32174577/

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