Note that there are some explanatory texts on larger screens.

plurals
  1. POImage displaying from database
    primarykey
    data
    text
    <p>I am trying to show images from database with next previous button.</p> <p>here's my code:</p> <pre><code>&lt;?PHP session_start(); $page = "voting.php"; include ('dbconnect.php'); $q = "SELECT * FROM vote_frames"; $r = mysql_query($q); while($row = mysql_fetch_array($r)){ $i_array[] = $row['frame_pic']; $i_array1[] = $row['frame_pic1']; $i_array2[] = $row['frame_pic2']; $id_array[] = $row['frame_id']; } $fpp = 1; $num_images = count($i_array); $image_path = "frames/"; $y = $fpp; if(!isset($_GET['first'])){ $first = 0; }else{ $first = (int) $_GET['first']; } $x = $num_images - 1; $z = $x - $y; if($first&gt;$z) { $first = $z; } $last = $first + $fpp; ?&gt; &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt; &lt;html&gt; &lt;/head&gt; &lt;body&gt; &lt;div&gt; &lt;?PHP $i = $first; $prev = $first-1; $next = $first +1; if($prev&lt;0){ $prev = 0; } ?&gt;&lt;a href="&lt;?PHP echo $page; ?&gt;?first=&lt;?PHP echo $prev; ?&gt;"&gt;Previous&lt;/a&gt;&lt;?PHP while($i&lt;$last) { $f = $image_path . $i_array[$i]; $f1 = $image_path . $i_array1[$i]; $f2 = $image_path . $i_array2[$i]; ?&gt; &lt;img src="&lt;?PHP echo $f; ?&gt;"&gt; &lt;img src="&lt;?PHP echo $f1; ?&gt;"&gt; &lt;img src="&lt;?PHP echo $f2; ?&gt;"&gt; &lt;?PHP $i++; } ?&gt;&lt;a href="&lt;?PHP echo $page; ?&gt;?first=&lt;?PHP echo $next; ?&gt;"&gt;&lt;Next&lt;/a&gt;&lt;?PHP ?&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Images are displaying but with a strange behavior that last record is not showing. Actually for testing when I echoed id of current showing record, it shows next's id so record is having id of next's.</p> <p>I know I can do it with jquery w/o any issue but I must use a way to store current showing pic's id in session so I can show current showing and its next picture's vote count in the graph below.</p> <p>Any take on it?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload