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))
{
$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

Output Buffering question
Hi all,

I've been trying to wrap my head around output buffering. So far I've found tons of

$_POST variable un-useable
I'm trying to use a $_POST variable in a mysql update statement but i can't use it for some unknown

Facebook status update API
Hello,

So, I'm trying to create my first Facebook application with PHP.

Basic ideas fo

How to refresh a parent page from a modal popup
Hi,I have a modal popup in which I need to upload a file and store in the database should give a mes

Posting Serialized Data Not Working
I am trying to send an object from one PHP file to another using POST. I serialize the object and th

How to use Substr
I want to check for the word CATEGORY: inside a string which can be CATEGORY: ITEM
and remove the

cURL Sending File as Post
This is a bit complicated, I'm just hoping someone else has run into this and knows how to do it a d

Remove letter from numeric textbox
I have a textbox that will search the employee database by entering in the employee ID and it will r

Which PHP-Editor do you think is the best?
Hi everyone,
Myself Brian Anderson. For the last 2 years i have been working a

Most basic form question ever?
Hello,

I want to use this snippet to make sure the fields in a form are ok before processing

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