Log in

View Full Version : Links help....



teppanyakiboyz
04-14-2007, 01:48 PM
Hi I'm a newbie here, I'm new to this, got a question here


Normally we key in text in the empty text box to look for data, for example:

<body>
<form method="post" action="data.php">
<input type="text" name="shoe_1">
<input type="submit" value="Submit Data">
</form>

my "data.php" will connect to mySQL and search for category "shoe_1" for air jordan when I type in "air jordan" in the blanks and press Submit Data button.


What if I want a normal link to do this? for example a simple links:

<body>
<a> Air Jordan </a>


so when user clicks on Air Jordan, it will run my data.php to connect to mySQL and search category "shoe_1" for Air jordan.


How do I do that? Any Idea?
Please Help....

Twey
04-14-2007, 01:55 PM
You can't do it via POST, but you can via GET:
<a href="data.php?shoe_1=air&#37;20jordan">Air Jordan</a>GET is more appropriate here anyway... POST is, by convention, used only for requests that do something more permanent than generate a page.

teppanyakiboyz
04-14-2007, 02:09 PM
Thanx for the reply.

Is the code for POST same as the GET? I've only changed the POST word into GET in my php file. but it won't work.

mburt
04-14-2007, 02:10 PM
I often use:

<a href="data.php?submit">Air Jordan</a>
with post data on the other end:

<?php
if (isset($_GET["submit"])) {
//do something
}
?>
But, as Twey said for generating pages, GET would be best.

I think using GET is better anyways, because it gives the user the ability to copy the url and use it later.

teppanyakiboyz
04-14-2007, 02:36 PM
what is the command should i put in to allow the text clicked to be auto recognize and match by the database and show details.

for example:
i created a webpage with:
<a href="data.php" target="diffpage">Air Jordan.

as the database exactly has a product name Air Jordan.

thank you

Twey
04-14-2007, 02:39 PM
Is the code for POST same as the GET?Pretty much, yes.
I've only changed the POST word into GET in my php file. but it won't work.It should do, I'd guess you've missed one. You can also use $_REQUEST, which checks both POST and GET data (and cookie data too).
what is the command should i put in to allow the text clicked to be auto recognize and match by the database and show details.

for example:
i created a webpage with:
<a href="data.php" target="diffpage">Air Jordan.

as the database exactly has a product name Air Jordan.It doesn't work like that. :) You have to put the data in your URL, it won't be magically picked up.

teppanyakiboyz
04-14-2007, 03:34 PM
Thanx you guys for the replies, but sorry, I'm quite confused. :)

OK, I'll provide more details about what I have.

Example of items in my SQL:
Shoe_ID-------Shoe_Name--------Shoe_Price
101------------Air jordan1-----------100.00
102------------Air jordan2-----------200.00
103------------Air jordan3-----------300.00



Example of my data.php file:
<?php
$Shoe_ID = $_POST['Shoe_z'];

..............and so on, there's no problem in my php cause it work




Example of my html file:
<body>
<form method="post" action="data.php">
<input type="text" name="Shoe_z">
<input type="submit" value="Submit Data">
</form>

So when I enter "Air jordan1", and click Submit Data. It will show:

Air jordan1 100.00

It worked. But now instead of entering Air jordan1 and press Submit, I wanna use a link like:

<a> Air Jordan </a>


so when I click on the Air Jordan link, it will show:

Air Jordan 100.00



Hope this is clear enough. HAHA.
Please help.

thetestingsite
04-14-2007, 03:43 PM
Place the link like so:



<a href="data.php?Shoe_z=Air&#37;20jordan1">Air Jordan</a>


Then change the php code from $_POST to $_GET like so:



<?php
$Shoe_ID = $_GET['Shoe_z'];


Hope this helps.

teppanyakiboyz
04-14-2007, 03:52 PM
Place the link like so:



<a href="data.php?Shoe_z=Air%20jordan1">Air Jordan</a>


Hope this helps.



What does the %20 mean?

thetestingsite
04-14-2007, 03:54 PM
It's just a space in the url, you could probably just put a simple space in between them, but not sure. I just did that as a precaution.
Hope this helps.

teppanyakiboyz
04-14-2007, 03:57 PM
It's just a space in the url, you could probably just put a simple space in between them, but not sure. I just did that as a precaution.
Hope this helps.

:) :):)


YES!!!! Thanx guys. Really appreciate your help. It work!!!

I did not put in the 20 previously.


Thanx alot:p