title: How to create an image slideshow from images in a mysql database
body: <p>I have a mysqli database and form which allows me to store an id, name and photo. The path of the photo is set to an "images" folder on the server. I have a query which can </p>
  
  <blockquote>
    <p>SELECT * FROM images WHERE name = $pagetitle.</p>
  </blockquote>
  
  <p>This works absolutely fine, outside of the javascript slideshow. When i put a php command in the javascript where it is looking for which images to display, the js only shows 1 image, and not ALL images.</p>
  
  <p>Any help would be appreciated, thanks.</p>
  
  <p>The section of the code in question is below...</p>
  
  <h2>index.php</h2>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>            &lt;!-- Image Slide Show Start --&gt;
    &lt;div style="display: flex; justify-content: center;"&gt;
    &lt;img align="middle" src="" name="slide" border=0 width=300 height=375&gt;
      
  &lt;script&gt;
  
  &lt;?php 
  require('dbconnect.php');
  $data = mysql_query("SELECT * FROM images WHERE name= '$pagetitle'");
  $image = mysql_fetch_array( $data );
  
  
  
  ?&gt;
  //configure the paths of the images, plus corresponding target links
  slideshowimages("&lt;?php echo "/images/".$image['photo'] . ""?&gt;")
  
  //configure the speed of the slideshow, in miliseconds
  var slideshowspeed=2000
  
  var whichlink=0
  var whichimage=0
  function slideit(){
  if (!document.images)
  return
  document.images.slide.src=slideimages[whichimage].src
  whichlink=whichimage
  if (whichimage&lt;slideimages.length-1)
  whichimage++
  else
  whichimage=0
  setTimeout("slideit()",slideshowspeed)
  }
  slideit()
  
  
  &lt;/script&gt; &lt;/div&gt;&lt;br&gt;&lt;br&gt;
        &lt;!-- Image Slide Show End --&gt;</code></pre>
  </div>
  </div>
  </p>