Jump to content

Recommended Posts

Hello. i am after some coding help, hope someonce can point me in the right direction. Passing variables via HREF and retrieving them with GET. Is there a way of appending multiplevariables to the URL?

 

<a href="?month=January">January</a>
<a href="?month=February">February</a>
<a href="?day=Monday">Monday</a>
<a href="?day=Tuesday">Tuesday</a>

 

eg. If i click the January link above my page will change to index.php?month=January. Then if i click Monday i would like my URL to change to index.php?month=January&day=Monday. Likewise if i have index.php?month=January&day=Monday and then click Tuesday i would like URL to replace day=Monday to day=Tuesday. Is this posssible at all? not sure where to start searching.

Link to comment
https://forums.phpfreaks.com/topic/176768-adding-replacing-variables-to-the-url/
Share on other sites

Sorry my question may have been unclear, your suggestion would work but I would rather keep it dynamic so users can elect to select a Month first, then if they want to drill down further they can select a Day as well. If i group them together as you suggested then i will have to provide a long list of URL's.

 

Ideally i would have a list of URL's January to December, then another list of URL's Monday to Sunday. A User can then select a month (eg. index.php?month=January) then they can select a day (eg. index.php?month=January&day=Monday). Then if they wanted to change month they could choose a new month (eg. index.php?month=February&day=Monday)

you're going to render the calendar each time a month is clicked. this gives you ample opportunity to customize the weekday links. something like:

 

/* you should always get a month parameter. i'd take the time to default
   this to the current month, but I can't remember how to do that off the top
   of my head */
$month = 'January';
if (isset($_REQUEST['month']) {
  $month = $_REQUEST['month'];
}

...

/* now you can use $month to customize the day links: */
<a href="?month=<?= $month; ?>&day=Monday>Monday</a>
<a href="?month=<?= $month; ?>&day=Tuesday>Tuesday</a>


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.