I can’t figure out how to make the previous function work. I want this to check if the mysql field ‘title’ of the last item of the array is equal to the current one and if it is not I want it to print the title.
$usernotes = mysql_query("select * from notes where user_id= '$user_id'");
Print "<table border=0>";
while($info = mysql_fetch_array( $usernotes ))
{
if( $info['title'] != prev($info['title') )
{
Print "<tr><td><a href=\"mainpage.php?note_id=".$info['title']."\">".$info['title'] . "</a></td></tr> ";
}
}
Print "</table>";
It gives me the error
Warning: prev() expects parameter 1 to be array
What should I do?
Thanks
Function prev() is for changing the current index when reading an array item by item.
But your loop is not reading an array, it is reading an SQL record set.
Here is something that should work :