Location: PHPKode > projects > PHP Manual Creator > adm/parent_page.php
<?php
require_once("../includes/config.php");
require_once("../includes/functions/func.global.php");
require_once("../includes/functions/loggincheck.php");
require_once("class.menu.php");

// Connect to database
db_connect($config);

$manuals = array();
$manual_id = 0;

$sql = "SELECT manual_id,manual_title FROM ".$config['db']['pre']."manuals ORDER BY manual_title";
$query_result = mysql_query($sql);
while ($info = @mysql_fetch_array($query_result))
{
	$manuals[$info['manual_id']] = $info;
	$manual_id = $info['manual_id'];
}

if(count($manuals) == 0)
{
	exit('You must create a manual first');
}
elseif(count($manuals) == 1)
{
	$_GET['manual'] = $manual_id;
}

if(isset($_GET['manual']))
{
	$sql = "SELECT page_id,page_title FROM ".$config['db']['pre']."pages WHERE page_id!='".validate_input($_GET['id'])."' AND manual_id='".validate_input($_GET['manual'])."' AND parent_id='0' ORDER BY page_title";
	$query_result = mysql_query($sql);
	while ($info = @mysql_fetch_array($query_result))
	{
		$pages[$info['page_id']] = $info;
	}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Choose Parent Page</title>
<script>
function pick_page(page,title,id)
{
	opener.pickpage(page,title,id);
	self.close();
}
</script>
<style type="text/css">
<!--
body,td,th {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 12px;
}
-->
</style></head>

<body>
<?php
if(!isset($_GET['manual']))
{
?>
Please choose the manual you are currently working on:<br>
<br>
<?php
foreach ($manuals as $key => $value)
{
	echo '<a href="parent_page.php?id='.$_GET['id'].'&manual='.$value['manual_id'].'">'.stripslashes($value['manual_title']).'</a><br>';
}
?>
<?php
}
else
{
?>
Please choose a page to use as the parent:<Br><br>
<?php
foreach ($pages as $key => $value)
{
	echo '<a href="javascript:pick_page('.$value['page_id'].',\''.$value['page_title'].'\',\''.$_GET['id'].'\');">'.stripslashes($value['page_title']).'</a><br>';
}
?>
<?php
}
?>
</body>
</html>
Return current item: PHP Manual Creator