using current() end() with mysql_fetch_array


I am a beginner at PHP and i’m trying to use current() and end() functions to display a slightly different layout for the last row of the array. I have been trying to find the solution but couldn’t. Here is the first part of the code:
while(list($underpageid, $underpageauthor, $underpagetitle, $underpagetarget, $underpagestatus, $underpagelevel_x, $underpagelevel_xx, $underpagelevel_xxx, $underpagepath) = mysql_fetch_array($underpageresult, MYSQL_NUM))

/* Here I would like to be able to say: If it’s not the last row, echo “blabla”, if it’s the last row, echo “BLABLA”, but it doesn’t work: */
if (current($underpageresult) != end($underpageresult)) {
echo “blabla”;

elseif (current($underpageresult) == end($underpageresult)) {
echo “BLABLA”;

All I get from this is that I am not passing an array.

Thank you very much for your help.

I understand $underpageresult is not an array, it is the mysql query variable. But then, how can I define the while look with the mysql_fetch_array so that I can determine which row is the last and slightly change the html layout for this last row using an if statement ?


What I do when I need to define whether or not we’ve ended up on the last row of the result set, is use mysql_num_rows() to determine how many rows there are in the resultset and keep track of the number of rows I’ve had within the while loop, and compare it to the total number of rows. If it matches, you know you have the last row :)

Sponsor our Newsletter | Privacy Policy | Terms of Service