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

List/Menu Box
On an edit page when you want something to select what a user has previously selected from the datab

Help: calling function
Hi,
Is it possible to call a php function on page close?
If yes, could you explain how and whe

form problem
below in the form action, i've put "test.php?w=$sw&h=$sh" but when i input the for

help need on ob_start()
Hi

I am a newbie in php, I have a code
Line number On/Off | Expand/Contract <?phpo

mail() problem
Hi Guys,

I've set up a contact email form. It sends the information fine, but it sends it to

Weird MySQL error, why am I recieving this?
PHP Code:


<?php require "global_settings.php"; ?>
<titl

a function to check directory depth
I'm working on a php script to upload files in to a set directory.
the user can select to upload

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

Displaying a clickable playername
I am going wrong somewhere with the mysql_query, can someone please put me straight?

$playern

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


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

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