gpt4 book ai didi

php - 将表二中的数据添加到表一中

转载 作者:行者123 更新时间:2023-11-29 04:22:59 24 4
gpt4 key购买 nike

我需要显示一个表格,显示将笑话输入数据库的用户。我有一个笑话名称“joke”的表和一个名为“author”的用户的表笑话表有 id、joketext、jokedate、authorid作者表有 id、姓名、电子邮件所以'authorid'与作者表中的'id'相同。

<?php
$con=mysqli_connect("localhost","user","password","ijdb");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$result = mysql_query("SELECT joke.id, joketext, name, email FROM joke INNER JOIN author
ON authorid = author.id");

echo "<form action='delete1.php' method='post'>
<table border='1'>
<tr>
<th>Joke</th>
<th>Date</th>
<th>Name</th>
<th>Email</th>
<th>Delete</th>
</tr>";

while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['joketext'] . "</td>";
echo "<td>" . $row['jokedate'] . "</td>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['email'] . "</td>";
echo "<td><input type='submit' name='deleteItem' value='".$row['id']."' /></td>";
echo "</tr>";
}
echo "</table>";

echo "</form></br>";

mysqli_close($con);
?>

我收到这个错误警告:mysqli_fetch_array() 期望参数 1 为 mysqli_result,第 22 行 C:\xampp\htdocs\kimmy\jokes\joke1.php 中给出的 bool 值和一张空 table

谢谢

最佳答案

应该是:

$result = mysqli_query($con, "SELECT joke.id, joketext, name, email FROM joke INNER JOIN author
ON authorid = author.id");

当您使用 mysqli 扩展时,您不能使用 mysql_query()

关于php - 将表二中的数据添加到表一中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18460022/

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