/    Sign up×
Community /Pin to ProfileBookmark

Click Link, Open PHP Page…

God, it’s been a while since I’ve dabbled with PHP, so please pardon the newbie-ness. 😮

Could someone please tell me how to set up clicking a hyperlink to open a PHP page? I have 5 anchor tag links on a “products.php” page, and I’d like to be able to pass parameters and open the appropriate pages. For example:

Item1 link would pass the item1 parameter to yield

[code]products.php?product=item1[/code]

Item2 link would pass the item2 parameter to yield

[code]products.php?product=item2[/code]

God, any help would definitely get the ball rolling again. ? Honestly, my Googles have not told me what I need to know.

Thanks in advance!

Regards,

bubbis

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@aaronbdavisMar 21.2006 — you need to collect the variables from teh GET array:[code=php]$product = $_GET['product']; [/code] then you can use the variable as you like.
Copy linkTweet thisAlerts:
@SheldonMar 21.2006 — id sugest a [url=http://php.net/switch]switch[/url]
Copy linkTweet thisAlerts:
@bubbisthedogauthorMar 21.2006 — Okay, I've read both of your responses (much appreciated), but I'm still lost on how to implement this. Do I put in my HTML:
[CODE]<a href="http://mysite.com/products?item=item1">
<a href="http://mysite.com/products?item=item2">[/CODE]

and then somewhere else in the HTML
[CODE]<?php
$product = $_GET('product');

switch (product)
{
case item1:
*dunno???*
break;

case item2:
*dunno???*
break;
}
?>[/CODE]


I'm sorry, but I'm not sure how I'm suppose to set this up. I would greatly appreciate it if I could get some more help. I honestly can find no step-by-step help with this on the Web. If you all know of any, I'd really appreciate it.

Thanks again,

bubbis
Copy linkTweet thisAlerts:
@bubbisthedogauthorMar 21.2006 — Thanks, aaronbdavis and Sheldon, for helping me. I figured it out by using aaron's advice first, getting the parameter from the URL, and then implementing the switch statements to write the segments of code under the 'true' results of the switch (thanks, Sheldon!). So, after some headache, it now works as I'd planned.

I find it strange that I could not find a fairly detailed tutorial on this, what I'd think to be, basic scenario. Oh, well, I guess sometimes it helps to do the grunt work to beat it into your head! ?

Thanks again,

bubbis
×

Success!

Help @bubbisthedog spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...