I have a mysql database connected with php. However, I want each row in the database to be a unique page. Could anyone please provide some sort of overview for how this would work. It is simple for me to display the results of the database as a complete table or selected rows, but I have difficulty in creating individual pages from unique rows.
Alright, first off you can't, or it will be difficult to create individual pages for each row of your table. You'll have to do it with one page and take use of the $_GET global to change which site you should view.
For instance site.php?id=1
site.php would look something like this roughly
<?php
$connect = mysql_connect('host', 'user', 'pass');
$select_db = mysql_select_db('database_name');
$id = mysql_real_escape_string($_GET['id']);
//Remove LIMIT 1 to show/do this to all results.
$query = 'SELECT `content` FROM `pages` WHERE `id` = '.$id.' LIMIT 1';
$result = mysql_query($query);
$row = mysql_fetch_array($result);
// Echo page content
echo $row['content'];
?>
With that you can request any id you want and retrieve the content of that row/page.
Put an id in your query string which matches the id in your database.
$sql = 'SELECT `content` FROM `articles` WHERE `id` = ' . (int) $_GET['id'];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With