what was seems to be wrong here? i would like to execute simple query that will list articles according to some catergories.
from the base url http://localhost/root/supercms/index-te ... write=live after choosing catergories, it returns blank result and returned url http://localhost/root/supercms/index-te ... rch=Search instead of http://localhost/root/supercms/index-te ... rch=Search which give some listing of the results...
bellow are the codes from login to index (main module).
login script
Code: Select all
<?php
require("config.php");
include("modlib.php");
conn_db($host, $user, $pass, 'superdb');
if($_POST['cmdLog']) // On POST execute statments.
{
$user = escval($_POST['per_user']);
$seek = "SELECT usr FROM user_mas WHERE usr = '$user'";
$flag = mysql_query($seek) or die('Problem:'.mysql_error());
$getusr = mysql_fetch_array($flag);
$pass = crypt_pass($_POST['per_pass']);
if(strcmp($user, $getusr['usr'])){
echo '<script type="text/javascript">alert("Invalid User or Password!"); window.location.href = "../login.html";</script>';
die();
}else{
$seek = "SELECT user_mas.id_mas, user_mas.usr, user_mas.auth, user_dtl.nme FROM user_mas, user_dtl
WHERE user_mas.usr = '$user' AND user_mas.psw = '$pass' AND user_mas.id_mas = user_dtl.id_dtl";
$flag = mysql_query($seek) or die('Problem: '.mysql_error());
$getrow = mysql_fetch_array($flag);
if(mysql_num_rows($flag) == 1){
session_start();
$_SESSION['session_id'] = genid($x);
$_SESSION['user_id_no'] = $getrow['id_mas'];
$_SESSION['user_auth_'] = $getrow['auth'];
$_SESSION['user_code_'] = $getrow['usr'];
header('Location: ../index-template.php?url_id=1&write=add');
}else{
echo '<script type="text/javascript">
alert("Invalid User or Password!")
window.location.href = "../login.html"
</script>';
die();
}
}
}// End POST statements.
?>index script
Code: Select all
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>SuperBalita |</title>
<link href="assets/reset.css" rel="stylesheet" type="text/css" />
<link href="assets/balita.css" rel="stylesheet" type="text/css" />
<link href="assets/formfeed.css" rel="stylesheet" type="text/css" />
</head>
<?php
include("modules/classlib.php");
session_start();
$user_control = new user_ui_class;
$url_id = $_GET['url_id'];
switch($url_id){
case 1:
$url_action = $_GET['write'];
switch($url_action){
case 'add': $parse_url = 'add'; break;
case 'live': $parse_url = 'live'; break;
} break;
case 2:
$url_action = $_GET['archieve'];
switch($url_action){
case 'append': $parse_url = 'append'; break;
case 'query': $parse_url = 'query'; break;
} break;
}
?>
<body>
<div id="wrap">
<table border="0" cellpadding="0" cellspacing="1" id="maintble" >
<tr>
<td id="w599"><div class="user_controlnav">
<ul>
<li class="point">Sign Out: <a href="modules/log_off.php"><?php echo $_SESSION['user_code_']; ?></a></li>
<?php $user_control->set_navigation($_SESSION['user_auth_']); ?>
</ul>
</div></td>
<td id="w181"><div class="navigation">
<ul>
<li class="in">Manage: <a href="#">Users</a></li>
<li><a href="#">Database</a></li>
</ul>
</div></td>
<td id="w181"><div class="cols">Date Here</div></td>
</tr>
<tr>
<td colspan="3"><div class="navigation">
<ul>
<li><a href="index-template.php?url_id=1&write=add">Gateway</a></li>
<li><a href="index-template.php?url_id=2&archieve=append">Archieve Manager</a></li>
</ul>
</div></td>
</tr>
<tr>
<td colspan="3" ><div class="navigation">
<ul>
<?php
switch($_GET['url_id']){
case 1: echo '<li><a href="index-template.php?url_id=1&write=add">Add Article</a></li>
<li><a href="index-template.php?url_id=1&write=live">Live Articles</a></li>'; break;
case 2: echo '<li><a href="index-template.php?url_id=2&archieve=append">Append Article</a></li>
<li><a href="index-template.php?url_id=2&archieve=query">Query Articles</a></li>'; break;
}
// $user_control->gotonav($_GET['url_id']);
?>
</ul>
</div></td>
</tr>
<tr>
<td colspan="3" id="feed">
<!-- module execution begin -->
<?php
switch($url_action){
case 'add': include('form.php'); break;
case 'live': include('live-1.php'); break;
case 'append': echo 'append to database'; break;
case 'query': echo 'query archieve'; break;
}
?>
<!-- module execution end -->
</td>
</tr>
</table>
</div>
</body>
</html>the query that supposed to be executed within the index
Code: Select all
<?php
require("modules/config.php");
include("modules/modlib.php");
conn_db($host, $user, $pass, 'superdb');
$location = $section = NULL;
// if(!isset($_GET['cmdDelete'])){
if(isset($_GET["mnuLocation"]) && is_numeric($_GET["mnuLocation"])){
$location = $_GET["mnuLocation"];
}
if(isset($_GET["mnuSection"]) && is_numeric($_GET["mnuSection"])){
$section = $_GET["mnuSection"];
}
$action = 'mnuLocation='.$location.'&mnuSection='.$section;
// }
?>
<form method="get">
<table border="0" cellpadding="0" cellspacing="1" id="signin">
<tr>
<td width="127" class="fldLabel" ><span>Filter:</span> </td>
<td width="440">
<select name="mnuLocation" id="mnuLocation">
<option value="null">- Location -</option>
<option value="1" <?php if($location == 1) echo " selected"; ?>>Cag. de Oro</option>
<option value="2" <?php if($location == 2) echo " selected"; ?>>Cebu</option>
<option value="3" <?php if($location == 3) echo " selected"; ?>>Davao</option>
<option value="4" <?php if($location == 4) echo " selected"; ?>>Gen. Santos</option>
</select>
<select name="mnuSection" id="mnuSection">
<option value="null">-- Section --</option>
<option value="1" <?php if($section == 1) echo " selected"; ?>>Balita</option>
<option value="2" <?php if($section == 2) echo " selected"; ?>>Opinyon</option>
<option value="3" <?php if($section == 3) echo " selected"; ?>>Kalingawan</option>
<option value="4" <?php if($section == 4) echo " selected"; ?>>Sports</option>
</select>
<input name="cmdSearch" type="submit" class="cmd" value="Search" id="cmdSearch" />
</td>
<td width="100"><input type="checkbox" name="checkbox" id="checkbox" class="chkpad" />
<input name="cmdLog" type="submit" class="cmd" value="Delete" id="cmdLog" /></td>
</tr>
<?php
if(!is_null($location) && is_numeric($location) && !is_null($section) && is_numeric($section)){
$query = 'SELECT news_mas.mas_id, news_mas.location, news_mas.section, news_mas.lock, news_dtl.date, news_dtl.title FROM news_mas, news_dtl
WHERE news_mas.mas_id = news_dtl.dtl_id AND news_mas.location = '.$location.' AND news_mas.section = '.$section.' ORDER BY news_dtl.date';
$result = mysql_query($query) or die('Error: '.mysql_error());
if(!mysql_num_rows($result) > 0){
echo '<script type="text/javascript">alert("No Articles Found!..")</script>';
exit;
}
// session_start();
while($ctr = mysql_fetch_array($result)){ //Begin While
$section = $ctr['section'];
$location = $ctr['location'];
switch($section){ // Begin Switch
case 1: $sec = 'Balita'; break;
case 2: $sec = 'Opinyon'; break;
case 3: $sec = 'Kalingawan'; break;
case 4: $sec = 'Sports'; break;
} // End Switch
switch($location){ // Begin Switch
case 1: $loc = 'CDO'; break;
case 2: $loc = 'CBU'; break;
case 3: $loc = 'DVO'; break;
case 4: $loc = 'GEN'; break;
} // End Switch
$_SESSION['article_id'] = $ctr['mas_id'];
// if(is_null($ctr['lock']) || $ctr['lock'] == 0){ // ?>
<!-- loop + -->
<tr>
<td width="127" class="fldLabel"> </td>
<td width="440">
<a href="view_article.php?article_id=<?php echo $ctr['mas_id']; ?>" target="_blank"><?php echo filval(charslen(48, $ctr['title'])); ?></a>
</td>
<td width="100"><input type="checkbox" name="checkbox" id="checkbox" class="chkpad" />
<input name="cmdLog" type="submit" class="cmd" value=" Edit " id="cmdLog" /></td>
</tr>
<!-- loop - -->
<?php }
} ?>
</table>
</form>vic