468,133 Members | 1,337 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,133 developers. It's quick & easy.

Dynamic Link/Content with PHP

Hi,
I've created a mySQL database with the fields id, title and content.
'ID' is a unique field. Any ideas on how I can use PHP to generate a
list of the titles which are links. When you click on a link you are
taken to a page with the content held in the database. I'm guessing the
generated links would be something like /page.PHP?pageid=x based on the
id, that's if this script is possible at all.

Sorry for being such a newbie, but I guess we all have to start somewhere.

Thanks,
Ben
Jul 27 '05 #1
3 2781
Ben Allen wrote:
Hi,
I've created a mySQL database with the fields id, title and content.
'ID' is a unique field. Any ideas on how I can use PHP to generate a
list of the titles which are links. When you click on a link you are
taken to a page with the content held in the database. I'm guessing the
generated links would be something like /page.PHP?pageid=x based on the
id, that's if this script is possible at all.

Sorry for being such a newbie, but I guess we all have to start somewhere.

Thanks,
Ben

Ben,

This is exactly what php does, and you seem to be off to a good start.
Have you tried writing any code yet or do you have any more specific
questions?

If you are just starting out, I would suggest first writing a webpage
which simply lists all the items in the database. If there are many
items, you might consider splitting them up into usable chunks of 10-20
per page.
http://www.php.net/manual/en/index.php
http://www.php.net/manual/en/ref.mysql.php

Once that is working, turn the list into a list of links, your proposed
url format looks fine, though I wouldn't name a page 'page.php', how
about 'display.php'.
http://idocs.com/tags/linking/_A.html
http://www.php.net/variables.external
Once you have completed those first two steps you should write the
display.php page, which retrieves the item details from the database
using the id you passed in the url (this can be retrieved from the $_GET
array in php.
http://www.php.net/variables.external
http://www.php.net/manual/en/reserve....variables.get
Jul 27 '05 #2
Carl wrote:
Ben Allen wrote:
Hi,
I've created a mySQL database with the fields id, title and content.
'ID' is a unique field. Any ideas on how I can use PHP to generate a
list of the titles which are links. When you click on a link you are
taken to a page with the content held in the database. I'm guessing
the generated links would be something like /page.PHP?pageid=x based
on the id, that's if this script is possible at all.

Sorry for being such a newbie, but I guess we all have to start
somewhere.

Thanks,
Ben


Ben,

This is exactly what php does, and you seem to be off to a good start.
Have you tried writing any code yet or do you have any more specific
questions?

If you are just starting out, I would suggest first writing a webpage
which simply lists all the items in the database. If there are many
items, you might consider splitting them up into usable chunks of 10-20
per page.
http://www.php.net/manual/en/index.php
http://www.php.net/manual/en/ref.mysql.php

Once that is working, turn the list into a list of links, your proposed
url format looks fine, though I wouldn't name a page 'page.php', how
about 'display.php'.
http://idocs.com/tags/linking/_A.html
http://www.php.net/variables.external
Once you have completed those first two steps you should write the
display.php page, which retrieves the item details from the database
using the id you passed in the url (this can be retrieved from the $_GET
array in php.
http://www.php.net/variables.external
http://www.php.net/manual/en/reserve....variables.get


Thanks for the quick reply Carl,
I've used php before, a basic form to add stuff to a database and also a
script to list from a database. It was the turning them automatically
into links and then clicking on that link to bring up a page filled from
a database that confused me. I haven't written any code for this
particular piece yet. I'm still not sure how to use the $_GET to
retrieve the information but I guess I'll figure it out, I've use $_get
before to pass an email address from one page to another (not very
securely I know, but it was more of a test script). Anyway, I'll give it
ago, thanks for the information.

Cheers,
Ben
Jul 27 '05 #3
Ben Allen wrote:
Hi,
I've created a mySQL database with the fields id, title and content.
'ID' is a unique field. Any ideas on how I can use PHP to generate a
list of the titles which are links. When you click on a link you are
taken to a page with the content held in the database. I'm guessing the
generated links would be something like /page.PHP?pageid=x based on the
id, that's if this script is possible at all.

Sorry for being such a newbie, but I guess we all have to start somewhere.

Thanks,
Ben

It seems I found what I need here:
http://www.php-mysql-tutorial.com/cms-php-mysql.php

If, after further reading, this isn't what I need I'll resort to using
my own code.

Thanks,
Ben
Jul 27 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Daniel Keller | last post: by
3 posts views Thread by NateDawg | last post: by
2 posts views Thread by JWL | last post: by
1 post views Thread by nsvmani | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.