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

I need some help with the IF command...
I have a large number of images in one section of my website with the .jpg format. I'm adding a bun

Curl timeout breaks script
So im having difficulties with skipping timeout error in curl
my script calls different functions

php slowing my site?
Hi all,

I think that one of the reasons that my site doesn't work fast is that the code is ve

How do I create a 2D game "camera" to follow player?
In J2ME programming I'm targeting MIDP 2.0 devices.

I'm using gamecanvas and I was thinking t

RSS feed - FeedList for WordPress
Hi,

I'm trying to alter the FeedList plugin for WordPress so that I can click on the title of

Undefined variable: adHTML
Hello:

While checking my site error logs, I've noticed one repetitive error that fills the lo

get the country of visitor and display content based on that
Hello all,

I have seen that Google analytics can tell you where a visitor is coming from and

mysql query with single quotes in a variable
$sitedetails = "INSERT INTO vars (address, sitename, description, ownername, theme) VALUES ('$u

.htpasswd Registration Form
Hi,
I wanted to make an htpasswd registration form.
I found this code on the internet but have

Upload Code Help
Hi everyone I need some help with a bit of code ive been working with for a while. I am completely s

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