php mysql_获取_数组重置
我想从mysql数据库打印一个列表,但是第一个列表项没有打印,因为mysql\u fetch\u数组被调用了两次。我试着重置,但没有成功。我该怎么办php mysql_获取_数组重置,php,mysql,Php,Mysql,我想从mysql数据库打印一个列表,但是第一个列表项没有打印,因为mysql\u fetch\u数组被调用了两次。我试着重置,但没有成功。我该怎么办 $current_goam = mysql_real_escape_string($current_goam); $current_content = mysql_real_escape_string($current_content); $note_content = mysql_query("select * from notes where
$current_goam = mysql_real_escape_string($current_goam);
$current_content = mysql_real_escape_string($current_content);
$note_content = mysql_query("select * from notes where title='$current_content' and goam='$current_goam' and user_id='$user_id'");
$note = mysql_fetch_array( $note_content );
if($note['type'] == 'list')
{
$note_type='list';
reset($note);
print "<table>";
while($note_info = mysql_fetch_array( $note_content ))
{
print "<tr><td>";
echo $note_info['body'];
print "</td>";
echo "<td><input type='checkbox' name='complete_goal' value='".$note_info['note_id']."'></input></td>";
print "</tr>";
}
print "</table>";
}
else{
echo $note['body'];
}
$current\u goam=mysql\u real\u escape\u string($current\u goam);
$current\u content=mysql\u real\u escape\u字符串($current\u content);
$note_content=mysql_query(“从notes中选择*,其中title='$current_content'和goam='$current_goam'和user_id='$user_id');
$note=mysql\u fetch\u数组($note\u content);
如果($note['type']=='list')
{
$note_type='list';
重置(附注);
打印“”;
而($note\u info=mysql\u fetch\u数组($note\u content))
{
打印“”;
echo$note_info['body'];
打印“”;
回声“;
打印“”;
}
打印“”;
}
否则{
回音$note['body'];
}
尝试此操作,而不是重置
mysql_data_seek($note_content, 0);
reset
适用于数组尝试在数组中加载数据,然后按需要使用它
$records = array();
while($r = mysql_fetch_array($note_content)) {
$records[] = $r;
}
请注意,如果您使用mysqli而不是mysql,则需要使用mysqli\u data\u seek($Note\u content,0);