title: How do I create a 'picture gallery' with pagination?
body: <p>I want my web page to look something like this: <a href="http://1x.com/photos/latest-additions/" rel="nofollow">http://1x.com/photos/latest-additions/</a></p>
  
  <p>I nearly mirrored it using only PHP (code found below). However, I decided I need to have a database after people from stackoverflow told me I need to, as it will be good in the long run. Anyways, so now I'm at a loss, learning MySQL. I want to make my page be very similar to that 1x page: with clickable pictures in a certain order (except I want to use a list instead of a table, for better web semantics), and pagination. Can somebody please tell how I can achieve this? I don't intend to be a programmer, I just want to know how to make that layout + pagination :[</p>
  
  <p>Can somebody please help? (by giving me a script, or tell me exactly what to do)</p>
  
  <p>Oh, and</p>
  
  <p>This was my original code. You can skip this, it's not necessary.</p>
  
  <pre><code>&lt;?php
  $rows_per_page = 2;
  $cols_per_page = 2;
  $image_href = '&lt;a href=/';
  $image_links = array('comics/randy&gt;', 'otherstuff/randy&gt;', 'otherstuff/randy&gt;', 'otherstuff/randy&gt;', 'otherstuff/randy&gt;', 'otherstuff/randy&gt;', 'otherstuff/randy&gt;', 'otherstuff/randy&gt;', 'otherstuff/randy&gt;');
  $img_srcs = '&lt;img src="https://s3.amazonaws.com/imagetitle/';
  $images = array();
  
  for($i = 1; $i &lt; 10; $i++)
  {
      $images[$i] = $i;
  }
  $image_ending = '.png" height="200" width="200" /&gt;&lt;/a&gt;';
  $image_break = '&lt;br /&gt;&lt;div class="timeago"&gt;&lt;div id="submitted"&gt;submitted&amp;nbsp;&lt;/div&gt;';
  $image_descriptions = array('&lt;abbr class="timeago" title="2011-03-13T07:24:17Z"&gt;&lt;/abbr&gt;&lt;/div&gt;', '&lt;abbr class="timeago" title="2011-03-13T07:24:17Z"&gt;&lt;/abbr&gt;&lt;/div&gt;', '&lt;abbr class="timeago" title="2011-03-13T07:24:17Z"&gt;&lt;/abbr&gt;&lt;/div&gt;', '&lt;abbr class="timeago" title="2011-03-13T07:24:17Z"&gt;&lt;/abbr&gt;&lt;/div&gt;', '&lt;abbr class="timeago" title="2011-03-13T07:24:17Z"&gt;&lt;/abbr&gt;&lt;/div&gt;', '&lt;abbr class="timeago" title="2011-03-13T07:24:17Z"&gt;&lt;/abbr&gt;&lt;/div&gt;', '&lt;abbr class="timeago" title="2011-03-13T07:24:17Z"&gt;&lt;/abbr&gt;&lt;/div&gt;', '&lt;abbr class="timeago" title="2011-03-13T07:24:17Z"&gt;&lt;/abbr&gt;&lt;/div&gt;', '&lt;abbr class="timeago" title="2011-03-13T07:24:17Z"&gt;&lt;/abbr&gt;&lt;/div&gt;');  
  $total_images = count($images);
  $images_per_page = $rows_per_page * $cols_per_page;
  $total_images = count($images);
  $total_pages = ceil($total_images / $images_per_page);
  $current_page = (int) $_GET['page'];
  if($current_page&lt;1 || $current_page&gt;$total_pages)
  {
      $current_page = 1;
  }
  
  //Get records for the current page
  $page_image_links = array_splice($image_links, ($current_page-1)*$images_per_page, $images_per_page);
  $page_images = array_splice($images, ($current_page-1)*$images_per_page, $images_per_page);
  $page_image_descriptions = array_splice($image_descriptions, ($current_page-1)*$images_per_page, $images_per_page);
  $slots = "&lt;table border=\"0\"&gt;";
  for($row=0; $row&lt;$rows_per_page; $row++)
  {
      $slots .= "&lt;tr&gt;";
      for($col=0; $col&lt;$cols_per_page; $col++)
      {
          $imgIdx = ($row * $rows_per_page) + $col;
          $img = (isset($page_images[$imgIdx])) ? "{$image_href}{$page_image_links[$imgIdx]}{$img_srcs}{$page_images[$imgIdx]}{$image_ending}{$image_break}{$page_image_descriptions[$imgIdx]}" : '&amp;nbsp;';
          $slots .= "&lt;td class='tables'&gt;$img&lt;/td&gt;";
      }
      $slots .= "&lt;/tr&gt;";
  }
  $slots .= "&lt;/table&gt;";
  
  //Create pagination links
  $first = "First";
  $prev  = "Prev";
  $next  = "Next";
  $last  = "Last";
  if($current_page&gt;1)
  {
      $prevPage = $current_page - 1;
      $first = "&lt;a href=\"w4rmoemfdoiemroifmeromfxdnxvl.php?page=1\"&gt;First&lt;/a&gt;";
      $prev  = "&lt;a href=\"w4rmoemfdoiemroifmeromfxdnxvl.php?page={$prevPage}\"&gt;Prev&lt;/a&gt;";
  }
  if($current_page&lt;$total_pages)
  {
      $nextPage = $current_page + 1;
      $next = "&lt;a href=\"w4rmoemfdoiemroifmeromfxdnxvl.php?page={$nextPage}\"&gt;Next&lt;/a&gt;";
      $last = "&lt;a href=\"w4rmoemfdoiemroifmeromfxdnxvl.php?page={$total_pages}\"&gt;Last&lt;/a&gt;";
  }
  
  ?&gt;
  &lt;html&gt;
  &lt;title&gt;&lt;/title&gt;
  &lt;head&gt;&lt;style type="text/css"&gt;
  #submitted {color: #888888; font-family:Verdana, Geneva, sans-serif; font-size: .8em; float:left;}
  .tables {padding-left: 20px; padding-right: 20px;}
  .timeago {color: #888888; font-family:Verdana, Geneva, sans-serif; font-size: .8em; float:right;}
  &lt;/style&gt;&lt;script src="/static/jquery-1.5.1.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script src="/static/jquery.timeago.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  jQuery(document).ready(function() {
    jQuery("abbr.timeago").timeago();
  });&lt;/script&gt;&lt;/head&gt;
  &lt;body&gt;
  &lt;h2&gt;Here are the records for page &lt;?php echo $current_page; ?&gt;&lt;/h2&gt;
    &lt;ul&gt;
      &lt;?php echo $slots; ?&gt;
    &lt;/ul&gt;
  Page &lt;?php echo $current_page; ?&gt; of &lt;?php echo $total_pages; ?&gt;
  &lt;br /&gt;
  &lt;?php echo "view more: {$next}"; ?&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Thank you!</p>