Forum Moderators: coopster

Message Too Old, No Replies

[PHP & Mysql] Not ordered correctly

         

basketmen

5:54 am on May 4, 2015 (gmt 0)

10+ Year Member



Hi guys, i have latest mysql version (5.5)

this is the screenshot of groupid field
[freakimage.com...]

i didnt touch anything yet, but some cells are not ordered correctly like this


but if i click groupid name in the top, it will ordered correctly like this
[freakimage.com...]





below php code output is like first screenshot above, that are not ordered correctly
please help how to make the output ordered correctly, like second screenshot above,
maybe add code like this : order by id asc
but where the right place to put it below?


$group_ids=explode(" ",$options['groupchoice_ids']);
$groupsql="SELECT id, title FROM " . TABLE_PREFIX . "thegroup WHERE";
$first=true;
foreach($group_ids as $value){
if(!$first){
$groupsql=$groupsql." OR ";
}
else{
$first=false;
}
$groupsql=$groupsql." id = '".$value."' ";
}

$kh_optionsgroup='<select name = "accounttype">';



$checksec = $db->query_read($groupsql);
if ($db->num_rows($checksec))
{

while($lboard = $db->fetch_array($checksec))
{
$kh_optionsgroup=$kh_optionsgroup."<option value ='".$lboard['id']."'>".$lboard['title']."</option>";

}
}
$verifystring='$human_verify';
$kh_optionsgroup=$kh_optionsgroup."</select>";

brotherhood of LAN

1:38 pm on May 4, 2015 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Before this line
$checksec = $db->query_read($groupsql);


You could try $groupsql .= ' ORDER BY id ASC';

For testing you can do something like
die($groupsql); just to see the query string itself.