Hey all,
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 none of the links are displayed. My php5 is set up so that I could see all of the errors but there are none displayed nor is there anything in the log.
Here are the function I am using:
Code: [Select]<?php
function confirm_query($result_set) {
if (!$result_set) {
die("Database query failed: " . mysql_error());
}
}
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;
}
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;
}
?>
Then I simply echo list_pages function on a page:
Code: [Select]<?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"); ?>
And below is the html code I see when I load the page:
Code: [Select]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Content Manager - Manage Pages</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="css/back_css.css" media="screen" />
</head>
<body>
<div id="wrapper">
<div id="header">
<div class="in">
<h1>Welcome To Your Content Manager!</h1>
</div>
</div>
<div id="content-wrapper"> <div id="content">
<div class="in">
<h2>This is the main content</h2>
</div>
</div>
</div>
<div id="left"><div class="in">
<h2>Menu</h2>
<ul>
<li><a href="manage_pages.php?name=Manage Pages"> Manage Pages </a></li>
<li><a href="manage_menu.php?name=Manage Menu"> Manage Menu </a></li>
<li><a href="manage_albums.php?name=Manage Albums"> Manage Albums </a></li>
<li><a href="manage_videos.php?name=Manage Videos"> Manage Videos</a></li>
<li><a href="manage_gigs.php?name=Manage Gigs"> Manage Gigs </a></li>
<li><a href="manage_news.php?name=Manage News"> Manage News</a></li>
</ul>
</div></div>
<div id="footer"><span>by AB</span></div>
</div>
</body>
</html>
Any ideas ?
Thanks in advance !
parse error
On my local machine I keep getting parse error for my footer. When I put it online, it doesn't show anything.I've searched on google but not found a solution for it. The error message:Parse error:
retrieving policy name inside the function called by this particular policy
Hi there,
New to Arrays
Hi I am new to PHP (a week and a half now) and I am just beginning to read about arrays. I understand simple arrays, associative arrays, and multidimensional arrays also. The book I am reading
Sharing PHP Sessions Across Domains
I am in the process of writing a script to share a php session across various domains I have.The problem I have, is getting php to access the php session. It gives me a persmission error. It seems the
php call servlet
I have done a php backup application .So there is a form that user pick some files to zip and download.Because of a problem with greek characters I make a servet (java) to create the zip.But I want
Problems with returning true or false in eval()'d code
Hi guys,Would appreciate some help with a problem when running eval() on a function that should return true or false. From php.net:Quoteeval() returns NULL unless return is called in the evaluated
error reporting
hey everyoneI have a production server in which I want error reporting but only on some pagesI haveini_set('display_errors', 1);ini_set('log_errors', 1);ini_set('error_log',
Keeping track of php uploads
Hello all.I was looking at the way PHP handles file uploads.It seems that PHP uses a temporarily directory and file name for file uploads. e.g. /var/www/virtual/SITE/phptmp/phpMhOniLThis file is
how to validate date using javascript
I need to validate date in textbox using javascript..The date is must be not greater than TODAY date and not less than before 3 months ..If either of these conditions is fails will show the prompt
Formatting echo from database
So I have a database that stores First and last names, then echos them back to a website, as of now the entire first and last name echos back (John Smith) I want the last name to just display the