'; ?> query('SELECT * FROM photos WHERE id=\'$i\'')) { showError('MySQL error'); } if ($result->num_rows == 0) { $row = array( 'author' => '--', 'description' => 'Zdjęcie usunięte', 'photo_name' => 'no_image.png', 'id' => $i ); } else { $row = $result->fetch_assoc(); $row['author'] = ($row['author']=='') ? 'Autor nieznany' : $row['author']; $row['description'] = ($row['description']=='') ? 'Brak opisu' : $row['description']; } ?> query('SELECT COUNT(id) FROM photos WHERE id<'.$id)->fetch_row(); #check if there are some previous photos $prev=$prev[0]; if($prev>0) { $prev=$DB->query('SELECT * FROM photos WHERE id<'.$id.' ORDER BY id DESC LIMIT 1;')->fetch_assoc(); #if yes, get the previous photo's data echo ''; #and send it } $next = $DB->query('SELECT COUNT(id) FROM photos WHERE id>'.$id)->fetch_row(); #check if there are some next photos $next=$next[0]; if($next>0) { $next=$DB->query('SELECT * FROM photos WHERE id>'.$id.' ORDER BY id ASC LIMIT 1;')->fetch_assoc(); #if yes, get the next photo's data echo ''; #and send it } ?>