Jump to content

Passing data with <a href....>


RobertSubnet

Recommended Posts

Greetings all.

 

I am using mysql_fetch_array() and a while loop to retrieve data from a MySQL database. The loop is also used to populate an associative array.

 

I would like to pass the retrieved data to another PHP script, preferably using an anchor tag with an href attribute. Is there a way to do this or am I stuck having to use a form/submit?

 

Thanks,

~Robert

Link to comment
Share on other sites

Depending on how much data, you can pass it via a GET in an <a href> tag, however, the best thing to do would be to get the information from the table again on the second page based on the criteria given to the first page.

 

Another option is to use sessions.

Link to comment
Share on other sites

So lets say I have a URL:

 

\\mywebsite.com/firstpage.php

 

In the firstpage.php script, I have a variable, $variable = 10 and I want to pass the value (10) to another script, lets say secondpage.php. Would the link on firstpage.php look like this:

 

<a href = mywebsite.com/secondpage.php?variable = 10>Click Me</a>

 

Then to access the $variable value (10) on secondpage.php, I would code it as:

 

$variable_on_secondpage_php = $_GET['variable'];

 

Thanks again.

Link to comment
Share on other sites

So lets say I have a URL:

 

\\mywebsite.com/firstpage.php

 

In the firstpage.php script, I have a variable, $variable = 10 and I want to pass the value (10) to another script, lets say secondpage.php. Would the link on firstpage.php look like this:

 

<a href = mywebsite.com/secondpage.php?variable = 10>Click Me</a>

 

Then to access the $variable value (10) on secondpage.php, I would code it as:

 

$variable_on_secondpage_php = $_GET['variable'];

 

Thanks again.

 

yup!

 

or to make sure the variable (whatever it is is passed),

 

<a href="mywebsite.com/secondpage.php?variable=<?php echo $variable; ?>">Click Me</a>

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.