/    Sign up×
Community /Pin to ProfileBookmark

GET value from HREF for use in PHP

Hello,

I have a simple HREF in a table such as:
<a href=”products.php” name=’cat’>Lighting</a>

I have tried various methods such as $_GET, $_SESSION to get the value ‘Lighting’ brought forward but I know im missing something.

Can anyone help

What I want to be able to do realistically is from the HREF statement, bring forward the value that is clicked so I can use it in a MYSQL statement.

Any help would be great.

Thanks

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@dodzAug 27.2007 — Hello,

I have a simple HREF in a table such as:

<a href="products.php" name='cat'>Lighting</a>

I have tried various methods such as $_GET, $_SESSION to get the value 'Lighting' brought forward but I know im missing something.

Can anyone help

What I want to be able to do realistically is from the HREF statement, bring forward the value that is clicked so I can use it in a MYSQL statement.

Any help would be great.

Thanks[/QUOTE]



It should be.

[CODE]<a href="products.php?cat=lightning">Lighting</a>[/CODE]
-----------------


to retreive it is.....
[CODE]$_GET["cat"]; // the value "lightning"[/CODE]
Copy linkTweet thisAlerts:
@nicelad_ukauthorAug 27.2007 — Thanks for this, it works a treat.

Do you know how to do the same in forms? I have the following form which uses $_POST, but would rather it use the same principle as you just described:


[CODE]<form name='manufacturerform' method='post' action='$PHP_SELF'>
<select name='catselect' onchange=manufacturerform.submit()>
<option value=''>--Select Category--</option>
<option value=''>All</option>
<option value='Lighting'>Lighting</option>
</select>
</form>[/CODE]


Thanks
Copy linkTweet thisAlerts:
@dodzAug 27.2007 — Thanks for this, it works a treat.

Do you know how to do the same in forms? I have the following form which uses $_POST, but would rather it use the same principle as you just described:


[CODE]<form name='manufacturerform' method='post' action='$PHP_SELF'>
<select name='catselect' onchange=manufacturerform.submit()>
<option value=''>--Select Category--</option>
<option value=''>All</option>
<option value='Lighting'>Lighting</option>
</select>
</form>[/CODE]


Thanks[/QUOTE]




Need some little tweaking on the form ?..... perhaps like.....

[CODE]echo [COLOR="Red"]'[/COLOR]<form name="manufacturerform" method="post" action="'.$PHP_SELF.'">
<select name="catselect" onchange="manufacturerform.submit()">
<option value="">--Select Category--</option>
<option value="All">All</option>
<option value="Lighting">Lighting</option>
</select>
</form> [COLOR="Red"]'[/COLOR]; [/CODE]


then to retreive is.....
[CODE]
$_POST["catselect"]; // all, lightning or empty.[/CODE]
Copy linkTweet thisAlerts:
@nicelad_ukauthorAug 27.2007 — Thanks dodz,

Is there no way of making the Form put the 'cat=lighting' in the title bar too? As this is the way forward I would prefer to go.

Thanks for all your help.

Richard
Copy linkTweet thisAlerts:
@dodzAug 27.2007 — You're welcome.....

oh...by the way... use this on the form:
[CODE]<form method="get" >[/CODE]
×

Success!

Help @nicelad_uk 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 6.16,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...