[php]<?PHP //Set $thisPage - ?page=
$thisPage=$_GET[‘page’];
//Start of SQL query
//Including mysql info file
include(‘inc/mysql.php’);
//open connection
$con = mysql_connect($server,$dbusername,$dbpasswrd);
//check if connection is valid, if not - error + error string.
if (!$con){die('Could not connect: ’ . mysql_error());}
//Select database
mysql_select_db($database, $con);
//Define SQL query
$result = mysql_query(“SELECT * FROM site_pages WHERE page = ‘$thisPage’”);
//Execute SQL query, and show content
while($row = mysql_fetch_array($result)){
$page = htmlspecialchars($row[‘page’]);
if($thisPage==$page){$sqlpage=$thisPage;}
//Check for valid page, before running SQL query.
//Start of SQL query
//Including mysql info file
include(‘inc/mysql.php’);
//open connection
$con = mysql_connect($server,$dbusername,$dbpasswrd);
//check if connection is valid, if not - error + error string.
if (!$con){die('Could not connect: ’ . mysql_error());}
//Select database
mysql_select_db($database, $con);
//Define SQL query
$result = mysql_query(“SELECT * FROM site_pages WHERE page = ‘$sqlpage’”);
//Execute SQL query, and show content
while($row = mysql_fetch_array($result)){
$headline = htmlspecialchars($row[‘pagetitle’]);
$date = htmlspecialchars($row[‘date’]);
$author = htmlspecialchars($row[‘author’]);
$content = htmlspecialchars($row[‘content’]);
?>
<?PHP echo $headline; ?>
- <?PHP echo nl2br($date); ?> - <?PHP echo nl2br($author); ?>
<?PHP echo nl2br($content); ?>
<?PHP }
//close connection
mysql_close($con);
?>[/php]
Hi, I’ve written this file - all it does is check the DB for the pages, if the page exist in the table - tjen it will read the row and show the contents.
I’m trying to figure how I can get it to show a page when “?page=” is set to nothing in the address bar? …
Like showing the first entry from the db?
Any ideas?