html - next and previous buttons using php -


this question exact duplicate of:

i'm reposting question because got 1 answer didn't work or @ all. i'm trying make php slideshow , i'm done need implement next , buttons thought going easy, apparently can't increment indexes in php?

$sql = "select pic_url pic_info"; $result = $conn->query($sql); $count = 0; $dir = "http://dev2.matrix.msu.edu/~matrix.training/holmberg_dane/"; $source = "gallery.php";  if ($result->num_rows > 0) { // output data of each row     $pic_array = array();     while ($row = $result->fetch_assoc()) {          $pic_array[$count] = $row['pic_url'];         $count++;     }      $index = 1;     echo "<img src= ' $dir$pic_array[$index]' />";      echo "<a href= '$dir$pic_array[$index + 1]'>next</a>";     echo "<a href= '$dir$pic_array[$index - 1]'>back</a>"; }    $conn->close();  ?> 

this code destined break. incrementing index means work array items 1 next last before runs key doesn't exist. however, can see trying do, need use concatenation, period in php, , remember not mix double , single quotes. should work you.

echo "<img src= ".$dir.$pic_array[$index]." />"; echo "<a href= ".$dir.$pic_array[$index + 1].">next</a>"; echo "<a href= ".$dir.$pic_array[$index - 1].">back</a>"; 

Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo