|
Posted by Nancy on 11/09/06 05:21
Having trouble getting this script to work. Errorr states query failed
when click on sections to sort.
$s = $HTTP_GET_VARS["sort"];
include("deskheader.php");
include("config.php");
function loadlist($s) {
Global $dbhost, $dbname, $dbuser, $dbpasswd;
switch ($s) {
case "title" :
$sortby = "title";
break;
case "author" :
$sortby = "author";
break;
case "section" :
$sortby = "section";
break;
case "category" :
$sortby = "category";
break;
case "subcat" :
$sortby = "subcat";
break;
case "division" :
$sortby = "division";
break;
case "subdiv" :
$sortby = "subdiv";
break;
default:
$sortby = "pageid";
}
$dbh = mysql_connect($dbhost, $dbuser, $dbpasswd) or die("Could
not connect");
mysql_select_db($dbname,$dbh) or die("Could not select database");
$q1 = "SELECT page.pageid, page.title, author.name,
section.name, category.name,
subcat.name, division.name,
subdiv.name
FROM page
INNER JOIN (author, section, category, subcat,
division, subdiv)
ON (author.authorid = page.authorid AND
section.sectionid = page.sectionid AND
category.categoryid = page.categoryid AND
subcat.subcatid = page.subcatid AND
division.divisionid = page.divisionid AND
subdiv.subdivid = page.subdivid)
ORDER BY $sortby";
$rslt = mysql_query($q1, $dbh) or die("Query failed");
echo "<table><tr><th colspan=9>Article List</th></tr>";
echo "<tr><th><a href=".$_SERVER['SCRIPT_NAME'].">Seq</a></th><th><a
href=".$_SERVER['SCRIPT_NAME']."?sort=name>Name</a></th>
<th><a href=".$_SERVER['SCRIPT_NAME']."?sort=title>title</a></th>
<th><a
href=".$_SERVER['SCRIPT_NAME']."?sort=author>author</a></th>
<th><a
href=".$_SERVER['SCRIPT_NAME']."?sort=section>section</a></th>
<th><a
href=".$_SERVER['SCRIPT_NAME']."?sort=category>category</a></th>
<th><a
href=".$_SERVER['SCRIPT_NAME']."?sort=subcat>subcat</a></th>
<th><a
href=".$_SERVER['SCRIPT_NAME']."?sort=division>division</a></th>
<th><a
href=".$_SERVER['SCRIPT_NAME']."?sort=subdiv>subdiv</a></th>
<th></th></tr>\n";
while ($row1 = mysql_fetch_array($rslt, MYSQL_ASSOC)) {
echo "\t<tr>\n";
[Back to original message]
|