I am running a site which I am trying to get into a MySQL database. Everything is working correctly - ie, I have the database set up, the header/footer files including correctly, the data being gathered... and all that good stuff. 😉
However, I have a problem. The code I am using now is:
<?php
$db = "localhost";
$dbuser = "myuser";
$dbpass = "mypass";
$dbdb = "mydb";
mysql_connect("$db", "$dbuser", "$dbpass") or die(mysql_error());
mysql_select_db($dbdb) or die(mysql_error());
$query = mysql_query("SELECT * FROM site"); // replace table with your table name
while($row = mysql_fetch_array($query)) {
echo $row["Content"] . "<br>";
}
?>
As you can see, this prints ALL the different Content lines. However, for a site, this is not what I want. :p
What I am wanting is to be able to select which content to echo.
eg - in the browser, the URL would be index.php?page=test
That would then echo the Content for the line where the page name is test.
I also have out the page title in the database, and want to be able to put that in the title tags in my header file.
I have seen this done before, and just want to know how to do it!
Thanks!
~Daskar