madjack87 Posted August 12, 2010 Share Posted August 12, 2010 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? Quote Link to comment https://forums.phpfreaks.com/topic/210586-help-with-mysql-automatically-generating-web-pages/ Share on other sites More sharing options...
Adam Posted August 12, 2010 Share Posted August 12, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/210586-help-with-mysql-automatically-generating-web-pages/#findComment-1098650 Share on other sites More sharing options...
cliffdodger Posted August 12, 2010 Share Posted August 12, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/210586-help-with-mysql-automatically-generating-web-pages/#findComment-1098663 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.