title: What should I do to make specific images show for certain file extension types?
body: <p>I'm trying to implement a php, mySQL Admin panel/dashboard which shows a small preview image of the file that has been uploaded, if the file is not a jpg, jpeg, png or gif then I would like to display a placeholder image.</p>
  
  <p>So for example if the uploaded file is actually a jpg, the preview column in the table would show the image associated to the file name stored in the db (this I have working) but if it's a pdf then it should show a stock/filler/predefined image of my choosing.</p>
  
  <p>I'm hoping to do this in php but have very limited knowledge in this area with this project being my first large php project.</p>
  
  <p>I have tried to implement this functionality using a js/jquery switch but have had no such luck, Code for the last attempt included below:</p>
  
  <hr>
  
  <pre><code> $(document).ready(function() {
  
   var fileName, fileExtension;
  
   fileName = event.target.innerHTML;
  
   fileExtension = fileName.replace(/^.*\./, '');
  
   switch (fileExtension) {
  
    case 'png': case 'jpeg': case 'jpg':
        $('#tableImg').attr("src","&lt;?php echo $row["fileName"]; ?&gt;");
        break;
  
    case 'zip':
        $('#tableImg').attr("src","images/pdf.png");
        break;
  
    case 'pdf':
        $('#tableImg').attr("src","images/pdf.png");
        break;
      }
  });
  </code></pre>
  
  <p>I am no longer using this method, it was just my last attempt to get it working.</p>
  
  <p>The preview column is currently called in the php file like so;</p>
  
  <pre><code>&lt;img id="tableImg"  class="admin-thumb" src="&lt;?php echo $row["fileName"]; ?&gt;" alt=""&gt;
  </code></pre>
  
  <hr>
  
  <p>I know that my current methodology will only allow the files with jpg, png and other image related extensions to show but I can't figure out how to swap out the <code>echo $row["filename"]</code></p>
  
  <p>What I think I'm after, and please correct me if I'm wrong is either an if, else if, else or a php switch. I just have no idea how to make it work the way mentioned earlier.</p>
  
  <p>To recap: 
  I need an assist making a preview column of a table show either the image associated to the file name/URL or if the file type is a zip, pdf or non image file it shows a placeholder image selected by me. I did have a screenshot to share but I don't have 10 rep to do so, yet.</p>
  
  <p>Any help is appreciated and my thanks in advance.</p>
  
  <p>Limur</p>