I have this code below that creates a combo dropdown list that the user can use to select how many images ($MAXEMLEMENTSPERPAGE) I have set caption to be 1 the problem is I can't figure out how to get the combo box to change the value of the user selected item to show that the number of images the user wants I am using $xml = simplexml_load_file ("xml/images.xml"); to load the image elements and then $maxpage to paginate the images if I change $cation to 5 then it displays 5 images per page the problem I have is at the moment I haven't found a way of passing the selected value to $caption to refresh the any help would be appriciated
<select name="mydropdownlist">
<?php
$caption = 1;
$options = array('2' => '2',
'3' => '3',
'4' => '4');
foreach($options as $value => $caption)
{
if(isset($_GET['caption']))
{
$caption = $_GET['caption']; //if page is specif
}
echo "<option value=\"$value\" selected=\"$value\">$caption</option>";
}
?>
</select>
<?php
$page = 0;
$MAXELEMENTSPERPAGE = $caption; //change this value to display how many elements per page you wish people to see
$maxPage = count($xml)/$MAXELEMENTSPERPAGE;
if(isset($_GET['page']))
{
$page = $_GET['page']; //if page is specif
}
?> <?php
for($i =$page * $MAXELEMENTSPERPAGE ; $i< ($page * $MAXELEMENTSPERPAGE ) +$MAXELEMENTSPERPAGE ; $i++)
{
//start the foreach loop
$imageProp = $i;
if($i >= count($xml))
{
break;
}
?>
Page:
<?php
if($page > 0){
?>
<a href=<?php echo $_SERVER["PHP_SELF"]."?page=".($page-1); ?>>Previous </a>
<?php
}
for($i = 0; $i< $maxPage; $i++ ){
//here we are making a loop for how many pages we have
//we then spawn a hyperlink for each page
//$Server["php_self"] returns the current page url
//then we append the page number to it
?>
<a href=<?php echo $_SERVER["PHP_SELF"]."?page=".$i; ?>><?php echo $i;?></a>
<?php
}
?>
<?php
if($page < floor($maxPage)){
?>
<a href=<?php echo $_SERVER["PHP_SELF"]."?page=".($page+1); ?>> Next </a>
<?php
}
?>
page with its new value