通过下一页和上一页传递变量

I start the page with the:

$selectedMenu = $_GET['selectedMenu'];

Then I have next and previous functions

<?php if ($prev) {  ?>
    <a href='?AID=<?=$prev?>&selectedMenu=$selectedMenu' style='background-image:url(/images/navDivider.png); background-position:right center; background-repeat: no-repeat; padding-bottom:4px; padding-top:4px;'>back&nbsp;&nbsp;</a>
<?php } else { ?>
    <a href='gallery.php?CID=<?=$CID?>&SCID=<?=$SCID?>&selectedMenu=$selectedMenu' style='background-image:url(/images/navDivider.png); background-position:right center; background-repeat: no-repeat; padding-bottom:4px; padding-top:4px;'>back&nbsp;&nbsp;</a>
 <?php } ?> 

<?php if ($next){ ?>
    <a href='?AID=<?=$next?>&selectedMenu=$selectedMenu'>&nbsp;next</a>             
<?php } ?>

There is a query that pulls the AID, CID, and SCID

But what happens is that the $selectedMenu won't stay after the fist page even though I am passing it in the url. Any clues why it's dropping out?

Try using a query string management class. For example: https://github.com/kenaniah/insight/blob/master/classes/querystring.php

Example usage:

<?php
$qs = new QueryString;
$qs->CID = $CID;
print "<a href='blah.php".$qs."'>Link</a>";
?>

Try this:

<?php if ($prev) {  ?>
    <a href="?AID=<?php echo $prev; ?>&selectedMenu=<?php echo $selectedMenu; ?>" style="background-image:url(/images/navDivider.png); background-position:right center; background-repeat: no-repeat; padding-bottom:4px; padding-top:4px;">back&nbsp;&nbsp;</a>
<?php } else { ?>
    <a href="gallery.php?CID=<?php echo $CID; ?>&SCID=<?php echo $SCID; ?>&selectedMenu=<?php echo $selectedMenu; ?>" style="background-image:url(/images/navDivider.png); background-position:right center; background-repeat: no-repeat; padding-bottom:4px; padding-top:4px;">back&nbsp;&nbsp;</a>
 <?php } ?> 

<?php if ($next) { ?>
    <a href="?AID=<?php echo $next; ?>&selectedMenu=<?php echo $selectedMenu; ?>">&nbsp;next</a>             
<?php } ?>

It was probably because you had a PHP variable in there without a surrounding PHP start and end tag. Also gave you proper echo statements.

Edit: Damn, realized you already got the answer.