Jump to content

[SOLVED] URL help


dennismonsewicz

Recommended Posts

I have the following code:

 

$i = 5;
							while($i <= 50)
							{
							   echo '<a style="display: inline block; padding: 5px;" href="' . $_SERVER['REQUEST_URI'] . '&limit=' . $i . '">' . $i . '</a>';
							   $i += 5;
							}

'

 

When a user clicks on a link the first time the URL is correct but if a user clicks on a second link the url appends the &limit=$i; IE: limit=5&limit=10&limit=15; i need it to replace the limit= everytime a link is clicked.

 

Help please?

Link to comment
Share on other sites

i am actually doing this in a different manner... LOL

 

updated code:

Results to display: 
						<select name="limit">
						<?php $i = 5;
							while($i <= 50)
							{
								if($i == $limit) {
									$s = "SELECTED";
								}
							   echo '<option value="' . $i . '" ' . $s . '>' . $i . '</option>';
							   $i += 5;
							}
						?>
						</select>
						<input type="submit" name="limit_submit" />
						# of Results currently displaying: <?php echo $limit; ?>

 

I have a new problem though. my if statement is not working... $limit is being passed via a function. how would i check to see if $limit = $i and if so then place the s var? $limit is being passed via a function

Link to comment
Share on other sites

If i understand correct, then like

 

                     <?php $i = 5;
                        while($i <= 50)
                        {
                           if($i == $limit) 
                              $s = "SELECTED";
                           else
                               $s = "";
                           echo '<option value="' . $i . '" ' . $s . '>' . $i . '</option>';
                           $i += 5;
                        }
                     ?>

 

Edit ignore that is it practically the same as you have, what function is passing limit? and try echoing limit within the loop to see if it is correct

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.