I want to insert information through a form to a databse (thats not the problem for me)...

From each entry into the database I want to create a page for that i.e. http://www.mydomain.com/somefile.php?article=7787

and that would intern lead the user to the 7787 article in the database. Same way for somefile.php?article=1, etc. etc.

How can I do this??

Thanks

raf

09-29-2003, 10:36 PM

Are you joking ?

You mean like George, who creates a new file each time you open a thread like showthread.php?threadid=26988

What you describe are typical html-links in a dynamically generated page.
For instance you select all articles of a firm and run the recordset in a while loop, building the urls like
<a href=\"somepage?article=" . $row['aritcleID'] . "\"> ...
and display them in a table like

They all point to the same page (somefile.php) and inside
somefile.php, you will grab the value for article (with $_GET['article'] and use it inside a select or so. Then you build the page with the results from the select and display them

The whole point in a db-driven webapplication is to have only a few dynamically build files that completely generic and are filled in with date from the db.

Or do i misunderstand the question ?

SDP2006

09-29-2003, 10:39 PM

No, you did not misunderstand the question. Now, could you show me the code of how to do this?

Thanks....

raf

09-29-2003, 11:08 PM

Euh ... OK. Say we have this page (page.php) where we select all articles from a specific catagory. So you build the selectstatement and run it, and then you loop through the recordset and build the list of links. Like:

So this will display a list a links. When you hoover over them, you'll see the adress in the adresbar looks like http://domain.com/somepage.php?article=145
http://domain.com/somepage.php?article=245
http://domain.com/somepage.php?article=8
etc

If the user clicks on one of them, somepage.php is loaded.

Now in this page, you will run some code for the selected article, like selecting all details of it, like

$select=("SELECT article.articlename, article.price, suppliers.suppliername, suppliers.suppliersadress, suppliers.supplierID FROM article INNER JOIN suppliers ON article.supID = suppliers.suopliersID WHERE articleID = " . $_GET['article'] ); // so the value is grabbed from the querystring and injected in the SQL statement
$result = mysql_query($select,$link);
then your code to check if the recordset isn't empty and to display the data from the recordset

When you display this data, you could display the suppliersnames as links to "... href=\"supplierdetails.ph?supplier=" . $row['supplierID'] . "\" ..." etc

You see ?

Spookster

09-29-2003, 11:14 PM

If you are going to create static pages from the data submitted in the form then why do you also want to store it in a database?

Like raf said if you just store it in the database you can then dynamically create the pages on the fly using a template. In other words, open the template stick in the data retrieved from the database and display it to the user.

SDP2006

09-29-2003, 11:26 PM

Well, then how can I dynamically create pages on the fly??

Thanks

Spookster

09-30-2003, 12:09 AM

Originally posted by SDP2006
Well, then how can I dynamically create pages on the fly??

Thanks

Ok just to make sure you folks from South Carolina understand....when we say dynamically create pages on the fly we mean they do not actually exist and are only created temporarily using the data from the database and putting that data into the code being stored in the template.

:D

SDP2006

09-30-2003, 12:44 AM

Oh yeah, spookster...

Might wanna change ur sig, Isabel is only what? 2 weeks old?

Nightfire

09-30-2003, 01:26 AM

Originally posted by SDP2006
Well, then how can I dynamically create pages on the fly??

Thanks

Do you even read the answers and code people give you?

SDP2006

09-30-2003, 01:36 AM

Of course I read them...geez:D

Nightfire

09-30-2003, 01:41 AM

*cough* look at raf's post

Spookster

09-30-2003, 01:52 AM

Originally posted by SDP2006
Oh yeah, spookster...

Might wanna change ur sig, Isabel is only what? 2 weeks old?

Is that better? :D

Yes as Nightfire pointed out raf has already discussed this a bit. Besides there are many threads on this if you use the search feature not to mention dozens of tutorials on this at places like www.zend.com and www.php.net . You just have to look around.