Help with ORDER BY


Posted on 16th Feb 2014 07:03 pm by admin

Hello. I would like to order by ascending States, then Cities, then Gyms in the following code, but I can't figure it out. If anyone could help, I would truly appreciated it!

if(isset($countryid))
{
Did you know?Explore Trending and Topic pages for more stories like this.
$sql = "Select * from ".TBGYM." G LEFT JOIN ".TBCITIES." CT ON G.cityid= CT.id LEFT JOIN ".TBSTATES." S ON CT.sid=S.id LEFT JOIN ".TBCOUNTRY." C ON S.cid=C.countries_id WHERE G.countryid=".$countryid;
}
if(isset($stateid))
{
$sql = "Select * from ".TBGYM." G LEFT JOIN ".TBCITIES." CT ON G.cityid= CT.id LEFT JOIN ".TBSTATES." S ON CT.sid=S.id LEFT JOIN ".TBCOUNTRY." C ON S.cid=C.countries_id WHERE G.stateid=".$stateid;
}
if(isset($cityid))
{
$sql = "Select * from ".TBGYM." G LEFT JOIN ".TBCITIES." CT ON G.cityid= CT.id LEFT JOIN ".TBSTATES." S ON CT.sid=S.id LEFT JOIN ".TBCOUNTRY." C ON S.cid=C.countries_id WHERE G.cityid=".$cityid;
}

$pager = new PS_Pagination($db, $sql, $noofrecords,$noofnavigators, "param1=valu1&param2=value2");

$pager->setDebug(true);

$rs = $pager->paginate();
if(!$rs) die(mysql_error());

while($row = mysql_fetch_assoc($rs)) {
$arr_result [] = $row;
}
No comments posted yet

Your Answer:

Login to answer
233 Like 17 Dislike
Previous forums Next forums
Other forums

Include ("Absolute Path") of a file?
I'm not sure what I'm doing wrong. I am writing my php code in the same directory of the file that

Move array index to end
Hey guys,
Quick question:

I have an array that looks like this:
Code: [Select]$var =

Script not running properly
Hello Everyone
This is a basic script for posting to a database. I'm not sure why it doesn't work

Please help - should be a simple fix.. driving me nuts
Everything seemed to be working fine. I have a table, it alphabetically lists a bunch of cities and

upload control not working with update panel
Hi,

I am working with Asp.Net FileUpload control with ajax update panel,

if i use the

Parse Error
Hi Guys,

I have a function in my class which returns a string link variable. The problem is i

help me fix these syntax errors...
I keep getting multiple syntax errors on this script like this one:

Parse error: syntax error

returning data from an ssh2_exec()
here's what i got.


$conn = ssh2_connect($this->_host);
ssh2_auth_password($c

Sorting JTable on more than just the values listed in the columns
I have a collection of objects that store (among other things) two integer values. I only want to di

filesize() returns 0
I have a socket program that runs in an infinite loop, listening for connections, in this socket I h

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash