gpt4 book ai didi

php - 查询返回资源 id #10

转载 作者:行者123 更新时间:2023-11-29 21:57:56 25 4
gpt4 key购买 nike

我想显示具有特定列名的行数。当我执行查询时,没有显示错误,但给出的输出只是资源 id #10。我是php和mysql领域的初学者。谁能帮我吗 ?我尝试了下面给出的代码

    $sql ="SELECT column1,column2 FROM table1 WHERE user_id='name' GROUP BY time_stamp";    
$result = mysql_query($sql);
$count=1;
while($row = mysql_fetch_array($result)) {
echo "<form action=table2.php method=GET>";
echo"<tr>";
$row_no="SELECT COUNT(time_stamp) FROM table1";
$row_num = mysql_query($row_no);



echo "<td>" .$count. "</td>";
echo "<td>" .$row["column1"]. "</td>";
echo "<td>" .$row["column2"]. "</td>";
echo "<td>" .$row_num. "</td>";
echo "<td>" ."<input class=btn type=submit value=Delete". "></td>";

echo"</tr>";
echo "</form>";
$count=$count+1;
}

最佳答案

您需要在第二个查询中获取计数。您可以使用 mysql_fetch_row 来完成此操作

$sql ="SELECT column1,column2 FROM table1 WHERE user_id='name' GROUP BY time_stamp";    
$result = mysql_query($sql);
$count=1;
while($row = mysql_fetch_array($result))
{
echo "<form action=table2.php method=GET>";
echo"<tr>";
$row_no= mysql_query("SELECT COUNT(time_stamp) as count FROM table1");
$row_num = mysql_fetch_row($row_no);
echo "<td>" .$row_num[0]. "</td>";
echo "<td>" .$row["column1"]. "</td>";
echo "<td>" .$row["column2"]. "</td>";
echo "<td>" .$row_num. "</td>";
echo "<td>" ."<input class=btn type=submit value=Delete". "></td>";
echo"</tr>";
echo "</form>";
$count=$count+1;
}

注意:不要使用 mysql_* 这些函数已被弃用。请改用 mysqli_*PDO

关于php - 查询返回资源 id #10,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32949201/

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