I have a list of 376 products in my database (with prices, descriptions, ect) and I was wondering how to have these pages automatically get created. Example would be: product1.php, product2.php, ..... product376.php. Thanks
That's not really a good practice, since you have the data in the database. You should create one dynamic page, which pulls the the based on a unique identifier, passed in the URL. Like: page.php?productid=3.
<?php // Make sure a database connection has been established at this point. $query = mysql_query(" SELECT * FROM table_name WHERE productid = " . intval($_GET['id']) . " LIMIT 1 ") OR die(mysql_error()); if (!$product = mysql_fetch_assoc($query)) { exit('Product not found.'); } echo $product['product_name']; echo $product['price']; // etc ?> PHP: This should get you started. You have to open the page like: page.php?id=4.
Awesome, I will play with this for awhile. I'll probably come back on the forums later for a few other questions. I gave you rep. Thanks! Best
Thanks for the great sample script. Is there a downloadable script template like this with SEO friendly URLs? I'm new to PHP and would like to create a dynamic website like this, but with SEO friendly URLs (using Apache or otherwise) and possibly some other features. Rather than try to modify this script, I wondered if there is a more robust script available somewhere, preferably free and with instructions. I've searched the web for "free php dynamic website script," "free php dynamic website builder," and related terms. These searches presented a few options: http://www.softswot.com/sitebuilderinfo.php http://www.ibdhost.com/help/templates/ http://www.thefreecountry.com/php/contentmanagement.shtml But I wondered what an experienced coder would recommend. BTW, I considered using Wordpress or Drupal, but those are far too complex for my needs. Maybe something like cakephp.org provides this. Any suggestions?