title: trouble displaying results of union select statement
body: <p>The following query works, but for some reason the first select statement is the only URL being displayed. Items from other tables are displayed, however, their URL is wrong.</p>
  
  <pre><code>$sql = "(SELECT postsID as postsID, postsSubject AS postsSubject, postsTimestamp AS timestamp
                  FROM   posts
                  WHERE  postsCategory = '$id')
              UNION 
                  (SELECT eventID as eventID, eventTitle as eventTitle, eventsTimestamp as timestamp
                  FROM   events
                  WHERE  eventLocation = '$id')
              ORDER BY timestamp DESC";
  </code></pre>
  
  <p>The information is being correctly displayed from both the events and posts table, but the results are appearing to ONLY come from the posts table.</p>
  
  <p>For example, say I have the following info</p>
  
  <pre><code>postsID |  postsSubject |  postsTimestamp
    1            post             123
  
  eventID |  eventTitle   | eventsTimestamp
    2           event            456
  </code></pre>
  
  <p>I have the following to display my results</p>
  
  <pre><code>   while($row = mysql_fetch_assoc($result)){
      ?&gt;
          &lt;tr&gt;&lt;td&gt;&lt;? echo '&lt;a href="viewevent.php?eventID=' . $row['eventID'] . '"&gt;' . $row['eventTitle'] . '&lt;/a&gt;' ; ?&gt;&lt;/td&gt;
          &lt;tr&gt;&lt;td&gt;&lt;? echo '&lt;a href="viewpost.php?postID=' . $row['postsID'] . '"&gt;' . $row['postsSubject'] . '&lt;/a&gt;' ; ?&gt;&lt;/td&gt;
      &lt;?  
          if(preg_match('/[0-9]/',$row['timestamp'])){        
              list($yyyy,$dd,$mm) = explode('-',$row['timestamp']);
                      $newDate = $dd."-".$mm."-".$yyyy;
              }
          ?&gt;
              &lt;td&gt;&lt;center&gt;&lt;? echo $newDate; ?&gt;&lt;/center&gt;&lt;/td&gt;&lt;/tr&gt;
          &lt;?
          }
          echo '&lt;/table&gt;';
  }
  </code></pre>
  
  <p>The output appears to be correct</p>
  
  <pre><code>post   123
  event  456
  </code></pre>
  
  <p>However, both results link to the following (respectively)</p>
  
  <pre><code>viewpost.php?id = 1
  viewpost.php?id = 2  //this should be viewevent.php
  </code></pre>