Jump to content

[SOLVED] Sessions and Queries


Gnub

Recommended Posts

Situation:

I have a query that is returning results.  the results are then posted on the page.   Each result is different from each other.  Next to each result, i want to place a button, that when clicked, will carry some of the fields from that specific result to another form,(on a different page/script) where some actions will be performed.

 

Im thinking the best way to do this is to use sessions.

 

Question:

How would i go about issuing a session variable to each result, and when that button is clicked, carry that 1 specific session over to the form, where i can carry on happy as Larry.

 

Could i do example:

 

While (there is data)
{
 Post results
 variable = field(s)
 session['variable']
 Link to new page
}

 

Thanks for any feedback.

Link to comment
Share on other sites

I'm not 100% sure of what you want, but would something like this do the trick?

 


if (isset(data)) {
form field with data
} else {
form field without data
}

 

Just set the value to a variable and if its set you have the form field with data have that variable as its value?

Link to comment
Share on other sites

Sorry, i'll try and explain it better.

 

On page1.php i have a query that displays the results in a list.

 

What i want to do, is take some of the fields from a result, and carry it over to another page, through the use of a button next to each result.

 

Pretty diagram:

***

Result1:

Name: Jo, Surname: Jones, DoB: 12/12/1960, House No: 12

[button]

 

Result2:

Name: Bob, Surname: Baluga, DoB: 12/11/1961, House No: 15

[button]

 

***

 

Let's say i press the [button] (Represents a link on the page) and on this new page, i have a form.  I want to take certain fields from that result(lets say Name, and DoB), and place it inside one of the form elements(TextArea).

 

Hope that helps.

Link to comment
Share on other sites

So you need to either pass them through using sessions or through the url. To go through the url just set each value like:

index.php?name=$name&dob=$dob then you can grab them from the url on the next page with $name = $_GET['name'];

and etc. I'm a little rusty on sessions as I haven't done them in like two years so this is as far as I can give help, I think. Hope it helps though!

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.