Forum Moderators: coopster

Message Too Old, No Replies

Passing information from page to page

what link a user clicked to populate the next page

         

mikejson

4:15 pm on Aug 29, 2003 (gmt 0)

10+ Year Member



I'm developing an FAQ, right now I have the questions print out as say links(idealy what I want) and I want to point them to the same page but giving the php script controlling that page the info of what they clicked(which questions) so I can populate that page with the question and answer.

Would I be using cookies for this? is there a simpler way I don't know about?

mack

4:27 pm on Aug 29, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



If I was you I would pass a variable to the php script. The variable could be a number or word that corosponds to one of your faqs.

the script should have a list of all available variables and a print command for each.

So if a user clicks on your first faq the query would be...?faq=1
Then the script would look through a text file or include to determine what happens with this variable.
The script then prints the info for faq one on screen.

You might wish to have a look through hotscripts etc. There are a lot of scripts "out the box" that do just this.

Hope this helps.

Mack.

justageek

4:54 pm on Aug 29, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You could just add hidden input types and assign the values to however many you need and read them on the next page. This will allow a post with anyone seeing the variables being passed.

mikejson

5:50 pm on Aug 29, 2003 (gmt 0)

10+ Year Member



Well, I have these FAQ's stored in a SQL database, I did include an FAQ id, so each Q and A are linked with an id(well they are in the same field, but it's faster to search on a number then a string so...

But anyway, I'm printing out links for the questions, and I want to direct to the next page, giving this page what link I chose. Basically I want to make it the same page cause I want to save myself some time. Just use the same page over and over, and retieve the answer from the database..

I'm not quite sure on the "click a link" and "telling the next page what link I clicked" part.

Little help?

justageek

7:51 pm on Aug 29, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The link to the next page would have the id attached to the link if the link is a get. If the link is a post then add the id in a hidden input. Grab the id as either the get or post and do the lookup again in the db and display it.

mikejson

3:34 pm on Sep 3, 2003 (gmt 0)

10+ Year Member



I'm totally lost on how we are doing this. Am I putting this in a form? All that my "Question" page shows right now is links. How do I make a link send information? I've only used forms and submitting it to get the data to the next page. Do I use javascript to send something?

justageek

3:46 pm on Sep 3, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Add the db identifier of the question to the end of your question link then do the query. So if your link is currently <a href="/questions.php">Question number one</a> it would then become <a href="/questions.php?id=1">Question number one</a>

The id will then show up the the questions.php page as the get variable $HTTP_GET_VARS['id']. Now you just take the id and do a lookup for it in your db and display whatever it is you want to display.

mikejson

4:08 pm on Sep 3, 2003 (gmt 0)

10+ Year Member



ahh.... duuuuuhhh, me...

Thanks alot man, that'll work perfectly

justageek

4:12 pm on Sep 3, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



:-)