gpt4 book ai didi

php - 使用超链接发送数据库中使用的变量,以使用 get 命令回显结果

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

我有一个包含从数据库提取信息的数组的表,我已将修复链接为超链接“单击我进行修复”我已输入链接以将变量发送到 php,该 php 将使用 $GET 来回显信息。

代码如下,我是php新手,一直在绞尽脑汁。我得到的唯一输出是“欢迎”。 (完成欢迎测试信息是否通过)

<div id=list>

<?php
// Create connection
$con=mysqli_connect('172.16.254.111',"user","password","Faults"); //(connection location , username to sql, password to sql, name of db)
// Check connection
if (mysqli_connect_errno($con))
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
//where statement in the sql syntax will select where in db to get infor, use AND to add another condition
$result = mysqli_query($con,"SELECT * FROM Fixes WHERE Product='Serv1U' AND Fault_type='Broadcast Manager'"); //this creates a variable that selects the database

//below is the echo statment to create the results in a table format, list collumn titles
echo "<table id=tables border='1'>
<tr>
<th>Products</th>
<th>Fault_type</th>
<th>Fault_Description</th>
<th>Fix</th>
</tr>";

//below is script to list reults in a table format, $row [row name on table]

while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['Product'] . "</td>";
echo "<td>" . $row['Fault_type'] . "</td>";
echo "<td>" . $row['Fault_Description'] . "</td>";
echo "<td><a href=\"idfix.php?Fix=" . $rows['Fix'] . "\">Click for Fix</a></td>"; //this is how you link into an echo, alsothe id=" hopefully means i can send ID information.
}
echo "</tr>";
echo "</table>";

// below closes the coonection to mysql
mysqli_close($con);

index.php:

Welcome <?php echo $_GET["Fix"]; ?>.

我迷路了。如有任何帮助,我们将不胜感激。

谢谢 ?>

最佳答案

这里只是一个错字吗? $GET 必须是 $_GET

它应该是$row['Fix']而不是$rows['Fix']!注意“s”!

关于php - 使用超链接发送数据库中使用的变量,以使用 get 命令回显结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17369208/

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