Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.21 KB | None | 0 0
  1. $smt=$conn->prepare('SELECT * FROM post');
  2. $smt->execute();
  3. <?php while($gdata=$smt->fetch(PDO::FETCH_OBJ)):?>
  4. <a href="#" class="media-left col-md-4 clearfix"><img src="posts/<?php echo $gdata->Post_Path; ?>" alt="image" class="post-image"/></a>
  5. <div class="media-body col-md-8 post-image-space pull-left">
  6. <div class="post-overview">
  7. <ul>
  8. <li class="post-category"><?php echo $gdata->Category;?></li>
  9. <li class="post-timestemp">Post on <?php echo $gdata->Post_Date;?></li>
  10. </ul>
  11.  
  12.  
  13. <a href="post-description.php?id=<?php echo $gdata->Id?>"><h4 class="media-heading h4"><?php echo $gdata->Title;?></h4></a>
  14. <p class="post-text"><?php echo $gdata->Post;?></p>
  15. </div>
  16.  
  17.  
  18. </div>
  19. <?php endwhile;?>
  20.  
  21. <?php
  22. include 'conn.php';
  23. $smt=$conn->prepare('SELECT * FROM post');
  24. $smt->execute();
  25. $row=$smt->fetch(PDO::FETCH_OBJ);
  26. $row->Post_Path;
  27. $ext=pathinfo($row,PATHINFO_EXTENSION);
  28.  
  29. ?>
  30.  
  31. <?php if($ext=='mp4')
  32.  
  33. {?>
  34.  
  35. <?php while($gdata=$smt->fetch(PDO::FETCH_OBJ)):?>
  36. <a href="#" class="media-left col-md-4 clearfix"><video class="post-image" controls>
  37. <source src="posts/<?php echo $gdata->$ext;?>" type="video/mp4">
  38. </video></a>
  39. <div class="media-body col-md-8 post-image-space pull-left">
  40. <div class="post-overview">
  41. <ul>
  42. <li class="post-category"><?php echo $gdata->Category;?></li>
  43. <li class="post-timestemp">Post on <?php echo $gdata->Post_Date;?></li>
  44. </ul>
  45.  
  46.  
  47. <a href="post-description.php?id=<?php echo $gdata->Id?>"><h4 class="media-heading h4"><?php echo $gdata->Title;?></h4></a>
  48. <p class="post-text"><?php echo $gdata->Post;?></p>
  49. </div>
  50.  
  51.  
  52. </div>
  53. <?php endwhile;
  54. }
  55.  
  56. elseif($ext=='jpg||jpeg||png')
  57. {
  58.  
  59. ?>
  60.  
  61. <?php while ($gdata = $smt->fetch(PDO::FETCH_OBJ)): ?>
  62. <a href="#" class="media-left col-md-4 clearfix"><img src="posts/<?php echo $gdata->Post_Path; ?>" alt="image"
  63. class="post-image"/></a>
  64. <div class="media-body col-md-8 post-image-space pull-left">
  65. <div class="post-overview">
  66. <ul>
  67. <li class="post-category"><?php echo $gdata->Category; ?></li>
  68. <li class="post-timestemp">Post on <?php echo $gdata->Post_Date; ?></li>
  69. </ul>
  70.  
  71.  
  72. <a href="post-description.php?id=<?php echo $gdata->Id ?>"><h4
  73. class="media-heading h4"><?php echo $gdata->Title; ?></h4></a>
  74.  
  75. <p class="post-text"><?php echo $gdata->Post; ?></p>
  76. </div>
  77.  
  78.  
  79. </div>
  80.  
  81. <?php endwhile;
  82. }?>
  83.  
  84. $info = new SplFileInfo('testing.jpg');
  85. var_dump($info->getExtension());
  86.  
  87. $smt=$conn->prepare('SELECT * FROM post');
  88. $smt->execute();
  89. <?php while($gdata=$smt->fetch(PDO::FETCH_OBJ)):
  90.  
  91. $mime = mime_content_type($gdata->Post_Path);
  92. if(strstr($mime, "video/")){
  93. // this code for video
  94. $file='';
  95. }else if(strstr($mime, "image/")){
  96. // this code for image
  97.  
  98. $file='<img src="posts/'.$gdata->Post_Path.'" alt="image" class="post-image"/>';
  99. }
  100.  
  101. ?>
  102. <a href="#" class="media-left col-md-4 clearfix"><?php echo $file?></a>
  103. <div class="media-body col-md-8 post-image-space pull-left">
  104. <div class="post-overview">
  105. <ul>
  106. <li class="post-category"><?php echo $gdata->Category;?></li>
  107. <li class="post-timestemp">Post on <?php echo $gdata->Post_Date;?></li>
  108. </ul>
  109.  
  110.  
  111. <a href="post-description.php?id=<?php echo $gdata->Id?>"><h4 class="media-heading h4"><?php echo $gdata->Title;?></h4></a>
  112. <p class="post-text"><?php echo $gdata->Post;?></p>
  113. </div>
  114.  
  115.  
  116. </div>
  117. <?php endwhile;?>
  118.  
  119. $fileInfo = pathinfo($gdata->Post_Path);
  120.  
  121. if($fileInfo['extension'] == 'png')
  122. {
  123. echo "It's an PNG";
  124. }
  125. elseif($fileInfo['extension'] == 'mp4')
  126. {
  127. echo "It's an MP4";
  128. }
  129.  
  130. $file_parts = pathinfo($filename);
  131.  
  132. switch($file_parts['extension'])
  133. {
  134. case "jpg":
  135. break;
  136.  
  137. case "exe":
  138. break;
  139.  
  140. case "": // Handle file extension for files ending in '.'
  141. case NULL: // Handle no file extension
  142. break;
  143. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement