I need a little help with this code....It seems as if it's not doing what it's supposed to do.
$sql = "SELECT * FROM images WHERE folder_id='$folder_id' ORDER BY image_id DESC";
$result = @($sql, $db_cnxn);
$totalrows = @mysql_num_rows($result);
for($i=0; $i <= $totalrows; $i++){
mysql_data_seek($result, $i);
$data = @mysql_fetch_array($result);
if ($data["image_id"] = $image_id){
if ($i >= 0){
if ($i != 0){
$i--;
mysql_data_seek($result, $i);
$data = mysql_fetch_array($result);
$next_prev = "<A HREF=\"$PHP_SELF?image_id=" . $data["image_id"] . "\">next</A>";
$i++;
}
if ($i != $totalrows){
$i++;
mysql_data_seek($result, $i);
$data = mysql_fetch_array($result);
$GLOBALS["next_image"] = $data["image_id"];
$next_prev .= " <A HREF=\"pop.php?image_id=" . $data["image_id"] . "\">prev</A>";
$i--;
}
}
break;
}
mysql_data_seek($result, $i);
}
@mysql_free_result ($result);
when the code write the next/prev buttons it seems to write the same image for each one......anyone see a problem?
Im trying to write in a next and previous button for a list of images......and if there is no next or prev.....don't write the buttons....