移动 mysql_fetch_array 指针 [英] Move mysql_fetch_array pointer
本文介绍了移动 mysql_fetch_array 指针的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在 while 循环中间移动 mysql_fetch_array 指针?像这样:
How can I move mysql_fetch_array pointer in middle of a while loop? something like this:
while ($subject = mysql_fetch_array($subject_qry))
{
$output = "<div class=\"left\" id=\"{$subject['id']}\"></div>";
next($subject);
$output = "<div class=\"right\" id=\"{$subject['id']}\"></div>";
return $output;
}
推荐答案
对于您的示例,有些地方没有意义.首先,在检索结果时不能将名称与 mysql_fetch_array 一起使用.Mysql_fetch_array 使用数字索引,而不是列名.其次,您不会从循环 while 语句中返回值.在循环过程中,您要么构建一个字符串,要么回显它.
There are a few things that don't make sense about your example. First, you can't use a name with mysql_fetch_array when retrieving the result. Mysql_fetch_array uses the numeric indices, not the column name. Second, you don't return a value from within a looping while statement. You'd either build up a string or echo it as you're progressing through the loop.
你有没有尝试过这样的事情:
Have you tried something like this:
$counter = 1;
while ($subject = mysql_fetch_array($subject_qry)) {
echo "<div class=\"left\" id=\"{$subject[0]}\"></div>";
mysql_data_seek($subject_qry,$counter);
$subject = mysql_fetch_array($subject_qry);
echo "<div class=\"right\" id=\"{$subject[0]}\"></div>";
$counter=$counter+2;
}
这篇关于移动 mysql_fetch_array 指针的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文