473,406 Members | 2,954 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Combo box does not change result

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 change the value of the user selected to loadthat page and shows 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
page with its new value
Expand|Select|Wrap|Line Numbers
  1. select name="mydropdownlist">
  2.     <?php
  3.     $caption = 1;                      
  4.  
  5.     $options = array('2' => '2',
  6.                      '3' => '3',
  7.                      '4' => '4');
  8.  
  9.             foreach($options as $value => $caption)
  10.        { 
  11.                 if(isset($_GET['caption']))
  12.         {
  13.             $caption = $_GET['caption'];   //if page is specif
  14.         }
  15.                     echo "<option value=\"$value\" selected=\"$value\">$caption</option>";
  16.  
  17.        }
  18.     ?>
  19.  </select>
  20. <?php
  21.     $page = 0;
  22.     $MAXELEMENTSPERPAGE = $caption; //change this value to display how many elements per page you wish people to see
  23.     $maxPage = count($xml)/$MAXELEMENTSPERPAGE;
  24.  
  25.     if(isset($_GET['page']))
  26.     {
  27.         $page = $_GET['page'];   //if page is specif
  28.     }
  29.  
  30.     ?> <?php
  31.     for($i =$page * $MAXELEMENTSPERPAGE ; $i< ($page * $MAXELEMENTSPERPAGE ) +$MAXELEMENTSPERPAGE ; $i++)
  32.                     {
  33.                         //start the foreach loop
  34.                         $imageProp = $i;
  35.  
  36.                         if($i >= count($xml))
  37.                         {
  38.                             break;
  39.                         }
  40.  ?>
  41.  Page:
  42. <?php
  43. if($page > 0){
  44.     ?>
  45.     <a href=<?php echo $_SERVER["PHP_SELF"]."?page=".($page-1); ?>>Previous </a>
  46.     <?php
  47. }
  48.  
  49. for($i = 0; $i< $maxPage; $i++ ){
  50.     //here we are making a loop for how many pages we have
  51.     //we then spawn a hyperlink for each page
  52.     //$Server["php_self"]  returns the current page url
  53.     //then we append the page number to it
  54.  
  55.     ?>
  56.  
  57.     <a href=<?php echo $_SERVER["PHP_SELF"]."?page=".$i; ?>><?php echo $i;?></a>
  58.     <?php
  59. }
  60. ?>
  61. <?php
  62. if($page < floor($maxPage)){
  63.     ?>
  64.  
  65.     <a href=<?php echo $_SERVER["PHP_SELF"]."?page=".($page+1); ?>> Next </a>
  66.     <?php
  67. }
  68. ?>
I am a newbie to php any help would be appreciated
Mar 13 '13 #1
0 1134

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: thenetflyer | last post by:
<?php /* Using a function to perform an operation to an occurrence before returning it to the replacement string does not work in preg_replace. Consider the following code in which I want to...
3
by: Diane Yocom | last post by:
Has anybody ever seen or written code for ASP that would mimic Access' multi-column combo box? Specifically, I have a drop down box that lists about 100 five-digit codes. Each of these codes has...
2
by: Dylan | last post by:
thanks for any comments. Here's the code //------------------------------------------------------------------ #include <iostream> class Base { protected: virtual int GetValue()=0;
1
by: Matt Evans | last post by:
Hi, this must have been asked for before, but I cannot see it. Hopefully this is very simple. I have a form which shows everything from a table. In this table is a picture field called photo....
9
by: Edwinah63 | last post by:
Hi everyone, Please let there be someone out there who can help. I have two BOUND combo boxes on a continuous form, the second being dependent on the first. I have no problem getting the...
2
by: bmdavis | last post by:
Hi, On my form I have one field of "City", and this in turn needs to effect "Township". When township is selected, the next field is distance, and for every 'township' there are 2 distances...
7
by: Mark Odell | last post by:
I'm running two different compilers against some hairy macros and one, gcc, doesn't like my token pasting result so much. It says, " "." and "foo" does not give a valid preprocessing token ". Some...
2
by: boopathisp | last post by:
set the value to combo box belonging to another combobox velue
1
by: blip | last post by:
I’m not sure I’ve posted in the correct place however…. I’ve been trying to get this to work for some time now. I have created 10 combo boxes on an Excel form. The first one contains a name,...
1
by: SD14 | last post by:
i am getting some weird errors when i try and complie my program first being the program2.cpp:7: error: expected unqualified-id before 'A' program2.cpp:8: error: expected unqualified-id before...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.