Jump to content

Help with mysql automatically generating web pages


madjack87

Recommended Posts

I am creating a drink recipe site.

 

So far I have created the mysql table and the page where i can enter in the drink name ingredients ect. and it inserts into the table.

 

Could some one point me in the right direction where when I make an entry into this table a new page is created from the content.

 

How would I go about doing this?

 

 

Link to comment
Share on other sites

You wouldn't actually create a new page as such. Basically once you have the data stored, you'd pass some type of unique identifier (normally an ID) through the URL parameters. Within the code you'd read this ID, perform the database query to return the associated data and then display it, or a fitting "page cannot be found" error message if not found of course.

Link to comment
Share on other sites

MrAdam is correct. However to accomplish that idea...

 

If your php script has a query in it along the idea of

$drink_page = mysql_query("SELECT * FROM drinks_table ORDER BY `id` ASC") or die(mysql_error());

for example. (you'll need something different, just an example)

 

Then loop through the data and start putting some html code into a php string mixed with your database results then output that variable to a file.

 

file_put_contents is probably the easiest way to do the final step

http://php.net/manual/en/function.file-put-contents.php

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.