I have this piece of code that set the query string depending on if a particular row is pulled from the database. The row in question is the one ive assigned to the variable upload. If it is set then one query string gets used and if it isnt another one gets used:

PHP Code:
$sql = "SELECT entries.*, categories.*, uploads.* FROM entries INNER JOIN categories ON(categories.category_id = entries.category_id) LEFT JOIN uploads ON (uploads.blog_id = entries.blog_id) ORDER BY entries.date_submitted DESC LIMIT 3";
$query = mysql_query($sql);

while ($row = mysql_fetch_array($query)) {
  $title = $row['title'];
    $body = substr($row['body'],0,400);
    $author = $row['author_id'];
    $date = $row['date_submitted'];
    $cat = $row['category_id'];
    $cat1 = $row['category'];
    if(isset($row['upload_id'])) {
        $upload = $row['upload_id'];
    else { $upload = NULL;}
      $blog_id  = $row['blog_id'];


<li><h3><?php echo $upload?><?php if(isset($upload)) { echo '<a href="individualarticle.php?f=1&blog_id=' .$blog_id;} else { echo '<a href="individualarticle.php?f=0&blog_id=' .$blog_id;} ?> "><?php echo $title?></a><?php if(isset($upload)) { echo ?><img src="pin.gif" /><?php ;}?></h3><p style="color: red; display: inline;">written by <?php echo $author?> on <?php echo $date?> Posted in<a href="categorypage.php?category_id=<?php echo $cat?>"><?php echo $cat1?></a></p><p><?php echo $body?></p></li>
<p><a href="individualarticle.php?blog_id=<?php echo $blog_id ?>">read on...</a></p>
Now it seems to work fine. If the row is set i can click through to the next page and everything works. The problem is that if the row is not set and the else is called and second query string gets used the $blog_id varaible doesnt get passed to the $_GET. When you click through the query string gets in to the url but theres no $_blog_id number on the end.

I cannot for the life of me work out why.

Could anyone spot the problem?