简体   繁体   English

MySQL不会从我的InnoDB表返回所有结果吗?

[英]MySQL isn't returning all results from my InnoDB table?

I am trying to get hold of 1 record from a MySQL table using PHP. 我正在尝试使用PHP从MySQL表中获取1条记录。 I have tried many different SELECT statements and had no luck so decided to ask PHP to show me ALL results for this certain column. 我尝试了许多不同的SELECT语句,但没有运气,因此决定要求PHP向我显示此特定列的所有结果。 It returned all results EXCEPT the first result. 它返回除第一个结果外的所有结果。

Im guessing this is why when it finds the result i need from the SELECT statement it does find a value but for some reason doesn't give it to me? 我猜测这就是为什么当它从SELECT语句中找到我需要的结果时,它确实找到了一个值,但是由于某种原因却没有给我吗?

Its probably really obvious but i accept defeat now, please help! 它可能确实很明显,但是我现在接受失败,请帮助!

$query="SELECT cw_id FROM unihubUpcoming";
$result = mysql_query($query) or die(mysql_error());

if(!$result){
 die('Query Failed!');
}


$row = mysql_fetch_assoc($result);

while ($row = mysql_fetch_array($result,MYSQL_NUM)) {
 echo $row[0];
}

All that code does is execute the $query and print all items out but the first result found. 这些代码所做的只是执行$ query并打印出所有项目,但找到的第一个结果。

Thank you guys! 感谢大伙们!

// get the first result
$row = mysql_fetch_assoc($result); 
// but don't do anything with it

// loop and display all subsequent results
while ($row = mysql_fetch_array($result,MYSQL_NUM)) { 
 echo $row[0]; 
} 
$row = mysql_fetch_assoc($result); // *

while ($row = mysql_fetch_array($result,MYSQL_NUM)) {
 echo $row[0];
}

What does the line marked * do? 标有*的行有什么作用? What happens when it is commented out? 注释掉后会发生什么?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM