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"; 1 1371
$sortby should be the exact column name. eg: 'author.name', not just
'author'
Nancy wrote:
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";
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Jerome Lefebvre |
last post by:
Hello,
Hope this will interest a few. I been working with a friend on the
problems given out during the "International Collegiate Programming Contest"
(ICPC) http://icpc.baylor.edu/icpc/ ....
|
by: Jim Hubbard |
last post by:
Are you up to speed on the difficulties in using the 1.1 .Net framework?
Not if you are unaware of the 1,596 issues listed at KBAlertz
(http://www.kbalertz.com/technology_3.aspx).
If you are...
|
by: 3f |
last post by:
Hello;
We have made a web application that people can download from our web site
and installed on:
Windows XP
Windows 2000 Professional
Windows 2003 Server
Windows 2000 Server
|
by: Corky |
last post by:
This works:
db2 SELECT DISTINCT PROBLEM_OBJECTS.PROBLEM_ID FROM PROBLEM_OBJECTS
INNER JOIN PROBLEMS ON PROBLEM_OBJECTS.PROBLEM_ID =
PROBLEMS.PROBLEM_ID WHERE INTEGER(DAYS(CURRENT DATE) -...
|
by: Kostas |
last post by:
I have seen that technique used occasionally, where people include an extra
sortby field in tables so as to create a different ordering scheme than that
derived by simply sorting the values of the...
|
by: BBFrost |
last post by:
We just recently moved one of our major c# apps from VS Net 2002 to VS Net
2003. At first things were looking ok, now problems are starting to
appear.
So far ...
(1) ...
|
by: Brian |
last post by:
NOTE ALSO POSTED IN
microsoft.public.dotnet.framework.aspnet.buildingcontrols
I have solved most of my Server Control Collection property issues.
I wrote an HTML page that describes all of the...
|
by: steven.ke |
last post by:
Hi all, I am trying to use the sortBy function in the prototype.js
library. Nevertheless, I can't work out what to include in the iterator
function. Can someone shed some light on this? Thanks in...
|
by: Sergistm |
last post by:
Hello World, :D
I have a problem that it is making me crazy, I hope you can help me.
I'm trying to execute a .exe file with the Procces.Start, and there
is no problem when the file is on my...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |