Hello everyone, this is my first post here. I'm new to PHP, and so far I'm loving what I have learned.
Here's my current problem-
I am attempting to have a dynamic section of my website that includes very short stories that I plan to store in a MySQL database. I have set up a password protected control panel with a form for me to type the stories into, and another field that contains a very short name for the story.
The database then creates a row containing 4 columns - a unique ID number, the story name, the content, and the date the story was added.
Everything works fine, but now I'm trying to set up a navigation bar that will look into the database, and for each record that is there, create a link to a template page that contains formatting for the story. This way I don't have to manually add a link in the database everytime a story is added.
What I envision is the id number from the database will be used in the navigation bar to set a variable. When that link is clicked, that variable carries over into the template page that loads, pulling the records out of the row corresponding to the variable.
This way I only need 1 template page that will format every story that I add.
The only way I know how to carry over variable is with form buttons, but I don't want a form button to accompany each story on the nav bar.
Any ideas?
Thank you very much-
Dave Heinzel
sending a variable when clicking a link
Moderator: General Moderators
-
daveheinzel
- Forum Newbie
- Posts: 8
- Joined: Tue Dec 02, 2003 10:47 pm
-
daveheinzel
- Forum Newbie
- Posts: 8
- Joined: Tue Dec 02, 2003 10:47 pm
Think I've got it!
Ok I think I've got this one figured out.
If I have each navigation link link to the template file, I can add onto the URL a ?num=$row[id]
This in turn points to: http://www.mydomain.com/template?num=1
So when the template is loaded, it pulls the $num variable down from the URL automatically, and all is good. This wouldn't work with sensitive or long information, but in this case, it's a perfect fit.
Any other ideas, or does this sounds good? It works for me with my current setup.
If I have each navigation link link to the template file, I can add onto the URL a ?num=$row[id]
This in turn points to: http://www.mydomain.com/template?num=1
So when the template is loaded, it pulls the $num variable down from the URL automatically, and all is good. This wouldn't work with sensitive or long information, but in this case, it's a perfect fit.
Any other ideas, or does this sounds good? It works for me with my current setup.
Re: Think I've got it!
[quote="daveheinzel"]So when the template is loaded, it pulls the $num variable down from the URL automatically, and all is good. This wouldn't work with sensitive or long information, but in this case, it's a perfect fit.
[quote]
THis is only the case if you have register_globals = On in your php.ini
The latest version have this set to off, so your script wouldn't work if your PHP version was upgraded.
Just something for you to be aware of. It would be better to make your script future proff-ish by doing this
Mark
[quote]
THis is only the case if you have register_globals = On in your php.ini
The latest version have this set to off, so your script wouldn't work if your PHP version was upgraded.
Just something for you to be aware of. It would be better to make your script future proff-ish by doing this
Code: Select all
$num = $_GET['num'];-
daveheinzel
- Forum Newbie
- Posts: 8
- Joined: Tue Dec 02, 2003 10:47 pm