title: Real big noobie here, how to use mysql so I can edit multiple pages easily?
body: <p>So right now, I've got a "gallery" system on my homepage of my site. Take a look:</p>
  
  <pre><code>&lt;?php
          $objConnect = mysql_connect("mydb.db","hello","mypass") or die(mysql_error());
          $objDB = mysql_select_db("mydb");
          $pic2 = "SELECT * FROM gallery";
          if (!isset($_GET['Page']))  $_GET['Page']='0';
          $pic1 = mysql_query($pic2);
          $Num_Rows = mysql_num_rows($pic1);
          $Per_Page = 16;   // Per Page
          $Page = $_GET["Page"];
          if(!$_GET["Page"])
          {$Page=1;}
          $Prev_Page = $Page-1;
          $Next_Page = $Page+1;
          $Page_Start = (($Per_Page*$Page)-$Per_Page);
          if($Num_Rows&lt;=$Per_Page)
          {$Num_Pages =1;}
          else if(($Num_Rows % $Per_Page)==0)
          {$Num_Pages =($Num_Rows/$Per_Page) ;}
          else
          {$Num_Pages =($Num_Rows/$Per_Page)+1;
              $Num_Pages = (int)$Num_Pages;}
          $pic2 .=" order  by GalleryID ASC LIMIT $Page_Start , $Per_Page";
          $pic1  = mysql_query($pic2);
  $cell = 0;
  $link2 = "SELECT * FROM gallery";
  $link1 = mysql_query($link2);
  $link = mysql_fetch_array($link1);
  $alt2 = "SELECT * FROM gallery";
  $alt1 = mysql_query($alt2);
  $alt = mysql_fetch_array($alt1);
  echo '&lt;div id="tablediv"&gt;&lt;table border="0" cellpadding="17" cellspacing="0" class="table"&gt;&lt;tr&gt;';
  while($pic = mysql_fetch_array($pic1))
  {if($cell % 4 == 0) {
      echo '&lt;/tr&gt;&lt;tr&gt;';}
  if($cell == 2) {
      echo '&lt;td&gt;reserved cell, ignore this&lt;/td&gt;';
  } elseif ($cell == 3) {
      echo '&lt;td&gt;reserved cell, ignore this&lt;/td&gt;';
  } else {
      echo '
      &lt;td&gt;&lt;a href="/' . $link["link"] . '.php"&gt;&lt;div class="image"&gt;&lt;img src="https://s3.amazonaws.com/images/' . $pic["pic"] . '" alt="' . $alt["alt"] . ' /&gt;&lt;/div&gt;&lt;/a&gt;&lt;/td&gt;'; }
      $cell++;
  }
  echo '&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;';
      ?&gt;
  </code></pre>
  
  <p>My table would be something like this:</p>
  
  <pre><code>CREATE TABLE `images` (
    `thumbnailID` int(11) NOT NULL auto_increment,
    `link` varchar(100) NOT NULL,
    `pic` varchar(100) NOT NULL,
    `alt` varchar(100) NOT NULL,
    PRIMARY KEY  (`thumbnailID`)
  ) ENGINE=MyISAM ;
  
  INSERT INTO `images` VALUES ('', 'stars/beezlebub', 'beezlebub', 'this is beezlebub');
  INSERT INTO `images` VALUES ('', 'nature/raretree', 'raretree', 'this is a rare tree');
  INSERT INTO `images` VALUES ('', 'nature/lions', 'lions', 'these are lions');
  INSERT INTO `images` VALUES ('', 'nature/tigers', 'tigers', 'these are tigers');
  etc. (you get the point)
  </code></pre>
  
  <p>Anyhow... as you can see, with this system, whenever I insert a new record, it automatically updates my gallery. Now my question is how can I make it so when I insert a new record, it doesn't just affect my homepage gallery, it affects the galleries on the other subsections of my website as well. Not sure what I mean? Here's an example:</p>
  
  <p>Say my site is called site.com . I also have subfolders for site.com, which include site.com/nature and site.com/stars . I want my site.com/nature to contain a gallery for only star photos and my site.com/stars to be a gallery for only star photos, while my homepage contains all images, including the nature and stars photos. but I don't want to manually update /nature or /stars by creating extra tables. Instead, I just want to use one huge table, which contains all the images on my site, but make it so I can specify whether I want my record to also display (/nature, /stars, etc) and not just home (which contains all images).</p>
  
  <p>I presume I would need another column (obviously) for specifying what other folders do I want my record to appear in, or maybe some conditional statements to determine which subfolder should my record also appear in and not just my homepage. Unfortunately, I'm a nooblet, so I'm asking if anyone can lend a hand. Thanks! </p>