I am learning php and my first goal is to create a simple CMS. At the moment I am stuck on not being able to pull page names and their id`s from my DB and combine them into a list of links (like so/manage_pages.php?page_id=1) so I could grab id`s later for update and delete pages. Problem is when I load the page nothing is displayed. My php5 is set up so that I could see all of the error but there are none displayed nor is there anything in the log.
Here are the function I am using:
Code: Select all
function confirm_query($result_set) {
if (!$result_set) {
die("Database query failed: " . mysql_error());
}
}
Code: Select all
function get_all_pages() {
global $connection;
mysql_select_db("content_MS", $connection);
$query = "SELECT *
FROM pages
ORDER BY id ASC";
$result_set = mysql_query($query, $connection);
confirm_query($result_set);
return $result_set;
}
Code: Select all
function list_pages(){
global $connection;
$result = get_all_pages();
$output = "<div>";
$output .= "<p>Select the page you would like to edit:</p>";
while($row = mysql_fetch_array($result))
{
$output .="<ul>";
$output .= "<li>";
$output .= "<a href=\"manage_pages.php?page=" . urlencode($row["id"]) ."\">{$row["page_name"]}</a></li>";
$output .="</ul>";
}
$output .="</div>";
return $output;
}
Code: Select all
<?php include ("includes/header.php"); ?>
<div id="content">
<div class="in">
<h2>This is the main content</h2>
<?php list_pages();?>
</div>
</div>
<?php include ("includes/footer.php"); ?>
Thanks in advance !
--best
A