title: upload and show(select) video in php
body: <p>I make a form through i can upload images and videos, the file's are stor in some folder and the path is stored in mysql table, now when i select the image file then i would show properly, my image selection code is...</p>
  
  <pre><code>$smt=$conn-&gt;prepare('SELECT * FROM post');
  $smt-&gt;execute();
   &lt;?php while($gdata=$smt-&gt;fetch(PDO::FETCH_OBJ)):?&gt;
          &lt;a href="#" class="media-left col-md-4 clearfix"&gt;&lt;img src="posts/&lt;?php echo  $gdata-&gt;Post_Path; ?&gt;" alt="image" class="post-image"/&gt;&lt;/a&gt;
          &lt;div class="media-body col-md-8 post-image-space pull-left"&gt;
              &lt;div class="post-overview"&gt;
                  &lt;ul&gt;
                      &lt;li class="post-category"&gt;&lt;?php echo $gdata-&gt;Category;?&gt;&lt;/li&gt;
                      &lt;li class="post-timestemp"&gt;Post on &lt;?php echo $gdata-&gt;Post_Date;?&gt;&lt;/li&gt;
                  &lt;/ul&gt;
  
  
              &lt;a href="post-description.php?id=&lt;?php echo $gdata-&gt;Id?&gt;"&gt;&lt;h4 class="media-heading h4"&gt;&lt;?php echo $gdata-&gt;Title;?&gt;&lt;/h4&gt;&lt;/a&gt;
              &lt;p class="post-text"&gt;&lt;?php echo $gdata-&gt;Post;?&gt;&lt;/p&gt;
            &lt;/div&gt;
  
  
  &lt;/div&gt;
  &lt;?php endwhile;?&gt;
  </code></pre>
  
  <p>now the problem is  that through the above way i can access the video file but it can't be shown? How can i check that the file is image or video?</p>
  
  <p>In my database the path will store like,  example.jpg/mypic.png, test.mp4,  how can i check the last extension of file?</p>
  
  <p>my updated code is...</p>
  
  <pre><code>&lt;?php
  include 'conn.php';
  $smt=$conn-&gt;prepare('SELECT * FROM post');
  $smt-&gt;execute();
  $row=$smt-&gt;fetch(PDO::FETCH_OBJ);
  $row-&gt;Post_Path;
  $ext=pathinfo($row,PATHINFO_EXTENSION);
  
  ?&gt;
  
  &lt;?php if($ext=='mp4')
  
  {?&gt;
  
      &lt;?php while($gdata=$smt-&gt;fetch(PDO::FETCH_OBJ)):?&gt;
      &lt;a href="#" class="media-left col-md-4 clearfix"&gt;&lt;video class="post-image" controls&gt;
              &lt;source src="posts/&lt;?php echo $gdata-&gt;$ext;?&gt;" type="video/mp4"&gt;
          &lt;/video&gt;&lt;/a&gt;
      &lt;div class="media-body col-md-8 post-image-space pull-left"&gt;
          &lt;div class="post-overview"&gt;
              &lt;ul&gt;
                  &lt;li class="post-category"&gt;&lt;?php echo $gdata-&gt;Category;?&gt;&lt;/li&gt;
                  &lt;li class="post-timestemp"&gt;Post on &lt;?php echo $gdata-&gt;Post_Date;?&gt;&lt;/li&gt;
              &lt;/ul&gt;
  
  
              &lt;a href="post-description.php?id=&lt;?php echo $gdata-&gt;Id?&gt;"&gt;&lt;h4 class="media-heading h4"&gt;&lt;?php echo $gdata-&gt;Title;?&gt;&lt;/h4&gt;&lt;/a&gt;
              &lt;p class="post-text"&gt;&lt;?php echo $gdata-&gt;Post;?&gt;&lt;/p&gt;
          &lt;/div&gt;
  
  
      &lt;/div&gt;
      &lt;?php endwhile;
  }
  
  elseif($ext=='jpg||jpeg||png')
  {
  
      ?&gt;
  
      &lt;?php while ($gdata = $smt-&gt;fetch(PDO::FETCH_OBJ)): ?&gt;
          &lt;a href="#" class="media-left col-md-4 clearfix"&gt;&lt;img src="posts/&lt;?php echo $gdata-&gt;Post_Path; ?&gt;" alt="image"
                                                                class="post-image"/&gt;&lt;/a&gt;
          &lt;div class="media-body col-md-8 post-image-space pull-left"&gt;
              &lt;div class="post-overview"&gt;
                  &lt;ul&gt;
                      &lt;li class="post-category"&gt;&lt;?php echo $gdata-&gt;Category; ?&gt;&lt;/li&gt;
                      &lt;li class="post-timestemp"&gt;Post on &lt;?php echo $gdata-&gt;Post_Date; ?&gt;&lt;/li&gt;
                  &lt;/ul&gt;
  
  
                  &lt;a href="post-description.php?id=&lt;?php echo $gdata-&gt;Id ?&gt;"&gt;&lt;h4
                          class="media-heading h4"&gt;&lt;?php echo $gdata-&gt;Title; ?&gt;&lt;/h4&gt;&lt;/a&gt;
  
                  &lt;p class="post-text"&gt;&lt;?php echo $gdata-&gt;Post; ?&gt;&lt;/p&gt;
              &lt;/div&gt;
  
  
          &lt;/div&gt;
  
      &lt;?php endwhile;
  }?&gt;
  </code></pre>
  
  <p><strong>I am not able to show video in my index page, how to show it, however i am able to show the image..</strong></p>
  
  <p>Any help would be appreciated.</p>