I want to print a list from a mysql database, but the first list item isn't printing because mysql_fetch_array is called twice. I tried reset but it didn't work. What should I do?
$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'];
}
mysql_fetch_array is a PHP function that will allow you to access data stored in the result returned from the TRUE mysql_query if u want to know what is returned when you used the mysql_query function to query a Mysql database. It is not something that you can directly manipulate. Syntax.
Speed-wise, the function is identical to mysql_fetch_array(), and almost as quick as mysql_fetch_row() (the difference is insignificant). Note: mysql_fetch_object() is similar to mysql_fetch_array(), with one difference - an object is returned, instead of an array.
mysqli_fetch_array() function: It is used to fetch rows from the database and store them as an array. The array can be fetched as an associative array, as a numeric array, or both. Syntax: mysqli_fetch_array(result, arrayType);
The fetch_array() / mysqli_fetch_array() function fetches a result row as an associative array, a numeric array, or both. Note: Fieldnames returned from this function are case-sensitive.
try this instead of reset
mysql_data_seek($note_content, 0);
reset
works for arrays
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With