Advertisement
cyberairman2013

ssgallery_functions.php

Jul 17th, 2013
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. <?php
  2. function view_image($photo_id) {
  3. $sql = "SELECT * FROM screenshots WHERE photo_id = $photo_id";
  4. $query = mysql_query($sql);
  5. $result = mysql_fetch_assoc($query);
  6.  
  7. echo '<img src="' . $result['image_link'] . '" />';
  8. echo '<table border="0"><tr><td><i>Image submitted by ' . $result['author'] . ' on ' . $result['date_sub'] . ' at ' . $result['time_sub'] . '</i> </td></tr><tr><td><h3>' . $result['header'] . '</h3></td></tr><tr><td>' . $result['desc'] . '</td></tr><tr><td><em>Voting System Coming Soon!!!!</em></td></tr></table>';
  9. }
  10. function image_from_database() {
  11. // use a running counter for flow control of the outer loop
  12. $runningcount = 0;
  13.  
  14. $r = mysql_query("SELECT * FROM screenshots WHERE photo_id IS NOT NULL AND photo_id !='' ORDER BY photo_id DESC") or die(mysql_error());
  15.  
  16. //Get # of images in results to use as upper limit for outer loop
  17. $img_ct = mysql_num_rows($r);
  18.  
  19. while ($runningcount <= $img_ct){
  20.  
  21. //rowcount reset to break content blocks
  22. $rowcount = 0;
  23.  
  24.  
  25. echo "<div class=\"row-fluid\">";
  26.  
  27. $runningcount++;
  28.  
  29. while(($rowcount <= 3) && $row = mysql_fetch_assoc($r))
  30. {
  31. $count = strlen($row['desc']);
  32. if ($count >= 50) {
  33. $row['desc'] = substr($row['desc'], 0, 50). "...";
  34. }
  35.  
  36.  
  37. $rowcount++;
  38. echo '<div class="span3">';
  39. echo '<img src="' . $row['image_link'] . '" /> <h4>' . $row['header'] . '</h4><p>' . $row['desc'] . '</p><a href="' . $row['image_link'] . '" rel="lightbox[apgssg]"><button class="btn" type="button">View Details</button></a>';
  40. echo '</div>';
  41. }
  42. echo "</div><br />";
  43.  
  44. }
  45. }
  46. function image_into_database($image_data) {
  47. array_walk($image_data, 'array_sanitize');
  48. $fields = '`' . implode('`, `', array_keys($image_data)) . '`';
  49. $data = '\'' . implode('\', \'', $image_data) . '\'';
  50.  
  51. mysql_query("INSERT INTO screenshots ($fields) VALUES ($data)") or die(mysql_error());
  52. }
  53. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement