jaggu2003
asked on
Sorting Order by both ASC & DESC
Hi All,
Here am posting one more question on PHP. Am new to this php programming so am using net to develop applications.
I have downloaded code for sort the DB fetched Results. Sorting order is working but its sorting only Ascending order, now I would like to set Desc or Asc.
Please help me to get sort out this problem.
Code is here like this
-------------------------- ---------- ---------- ---------- ----
$default_sort = "username";
if (!isset ($_GET['order']))
{
$order = $default_sort;
}
else
{
$order = $_GET['order'];
}
$result_id=$sql->query("SE LECT * FROM ".$database["table_prefix" ]."users WHERE is_active=1 ORDER BY $order");
echo "<b>".$lang["user_list"][" active_use rs"]."</b> <br>".str_ replace("< _COUNT_>", $sql->num_rows($result_id) , $lang["user_list"]["active _users_cou nt"])."\n" ;
echo "<table width='100%' border='0' cellpadding='0' cellspacing='1' class='txt'>\n";
echo " <tr class='tableheader' bgcolor='#cccccc'>\n";
echo " <td width='15%' bgcolor='#cccccc'><a href=".$general["site_path "]."/admin /user_list .php?order =username> ".$lang["m enu"]["use r"]["login "]["userna me"]."</a> </td>\n";
echo " <td width='20%' bgcolor='#cccccc'><a href=".$general["site_path "]."/admin /user_list .php?order =Name>".$l ang["name" ]."-".$lan g["LastNam e"]."</a>< /td>\n";
echo " <td width='12%' bgcolor='#cccccc'><a href=".$general["site_path "]."/admin /user_list .php?order =graduate_ year>".$la ng["my_inf o"]["gradu ate_year"] ."</a></td >\n";
echo " <td width='16%' bgcolor='#cccccc'><a href=".$general["site_path "]."/admin /user_list .php?order =auth>".$l ang["authe ntication" ]."</a></t d>\n";
echo " <td width='26%' bgcolor='#cccccc'><a href=".$general["site_path "]."/admin /user_list .php?order =last_logi n>".$lang[ "last_logi n"]."</a>< /td>\n";
echo " <td width='1%'> </td>\n";
echo " <td width='1%'> </td>\n";
echo " <td width='1%'> </td>\n";
echo " </tr>\n";
echo " </table>\n";
------------------------
Thanks for your time & inputs
Jaggu Joshi
Here am posting one more question on PHP. Am new to this php programming so am using net to develop applications.
I have downloaded code for sort the DB fetched Results. Sorting order is working but its sorting only Ascending order, now I would like to set Desc or Asc.
Please help me to get sort out this problem.
Code is here like this
--------------------------
$default_sort = "username";
if (!isset ($_GET['order']))
{
$order = $default_sort;
}
else
{
$order = $_GET['order'];
}
$result_id=$sql->query("SE
echo "<b>".$lang["user_list"]["
echo "<table width='100%' border='0' cellpadding='0' cellspacing='1' class='txt'>\n";
echo " <tr class='tableheader' bgcolor='#cccccc'>\n";
echo " <td width='15%' bgcolor='#cccccc'><a href=".$general["site_path
echo " <td width='20%' bgcolor='#cccccc'><a href=".$general["site_path
echo " <td width='12%' bgcolor='#cccccc'><a href=".$general["site_path
echo " <td width='16%' bgcolor='#cccccc'><a href=".$general["site_path
echo " <td width='26%' bgcolor='#cccccc'><a href=".$general["site_path
echo " <td width='1%'> </td>\n";
echo " <td width='1%'> </td>\n";
echo " <td width='1%'> </td>\n";
echo " </tr>\n";
echo " </table>\n";
------------------------
Thanks for your time & inputs
Jaggu Joshi
ASKER
hey minichiken,
Its working fine, I have set DESC order for LAST_LOGIN column. but when clicking second time on same link its not changing to ASC order. Its permanently set the order to DESC.
Any suggestion to change sorting order vice-versa.
Thanks buddy,
Jaggu Joshi
Its working fine, I have set DESC order for LAST_LOGIN column. but when clicking second time on same link its not changing to ASC order. Its permanently set the order to DESC.
Any suggestion to change sorting order vice-versa.
Thanks buddy,
Jaggu Joshi
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thank you guys for helping.
Can u guys chk this question;
https://www.experts-exchange.com/questions/21184380/How-to-solve-this-Warning-mysql-fetch-object.html
I appreciate your time & inputs
Jaggu Joshi
Can u guys chk this question;
https://www.experts-exchange.com/questions/21184380/How-to-solve-this-Warning-mysql-fetch-object.html
I appreciate your time & inputs
Jaggu Joshi
for ascending: $result_id=$sql->query("SE
or $result_id=$sql->query("SE