Jump to content

Recommended Posts

Hi guys

i need help whit select sorting, ASC or DSC.

 

code:

if (isset($_GET['mod']) && $_GET['mod']=='stored'){
	if (isset($_POST['brisi_poraki'])){
	$result = dbquery("DELETE FROM ".$db_prefix."zelbi WHERE id IN('" . implode("','", $_POST['add_check_mark']) . "')");
	redirect(FUSION_SELF);
}
$sort = $_GET['sort'];
if (empty($sort)){
	$sort = "DESC";
}
$rows = dbcount("(id)", "zelbi", "status='1'");
   if (!isset($rowstart) || !isNum($rowstart)) $rowstart = 0;
     echo "<form name='brisi_poraki' method='post' action='".FUSION_SELF."?mod=stored'>\n";
     echo "<div align='center'><img src='".IMAGES."dj.png' border='0'></div>";
     echo "<div align='left'><select onChange=\"document.form.submit();\" name='sortiraj'><option>Select</option><option value='ASC'>ASC</option><option value='DESC'>DESC</option></select></div>";
     echo "<table cellpadding='0' cellspacing='1' width='100%' class='tbl-border'>";
     echo "<tr><td class='tbl1' align='center' colspan='5'><a href='dj.php?mod=objaveni'>".$locale['015']."</a> - <a href='#' onclick=\"window.location = 'JavaScript:window.location.reload()';\"/>Refresh</a> - <a href='dj.php'>".$locale['016']."</a></td></tr>";
     echo "<tr><td class='tbl1'>ID</td>\n<td class='tbl1'>".$locale['010']."</td>\n<td class='tbl1'>".$locale['011']."</td>\n<td class='tbl1'>".$locale['021']."</td>\n<td class='tbl1'>".$locale['012']."</td>\n<tr>";
   if ($rows != 0) {
   $result = dbquery("SELECT * FROM ".$db_prefix."zelbi WHERE status='1' ORDER BY id ".$sort." LIMIT $rowstart,$broj");
     while ($data = dbarray($result)) {
     	if (iSUPERADMIN){
     	echo "<tr><td width='1%' class='tbl2'>".$data['id']."</td>\n<td class='tbl2 width='10%'>".$data['korisnik']."</td>
        <td class='tbl2' width='85%'>".$data['muzicka_zelba']."</td>\n<td class='tbl2'>".date("d-m-Y", $data['date'])."</td>\n<td align='center' class='tbl2'><input type='checkbox' name='add_check_mark[]' value='".$data['id']."' /></td></tr>";
     	} else {
   echo "<tr><td width='1%' class='tbl2'>".$data['id']."</td>\n<td class='tbl2 width='10%'>".$data['korisnik']."</td>
        <td class='tbl2' width='85%'>".$data['muzicka_zelba']."</td>\n<td class='tbl2'><a href='#'>".$locale['014']."</a></td></tr>";
     }
    }
    echo "<script type='text/javascript'>"."\n"."function setChecked(frmName,chkName,val) {"."\n";
	echo "dml=document.forms[frmName];"."\n"."len=dml.elements.length;"."\n"."for(i=0;i < len;i++) {"."\n";
	echo "if(dml.elements[i].name == chkName) {"."\n"."dml.elements[i].checked = val;"."\n";
	echo "}\n}\n}\n</script>\n";
  echo "<tr><td colspan='5' class='tbl1' align='right'><a href='#' onclick=\"javascript:setChecked('brisi_poraki','add_check_mark[]',1);return false;\">".$locale['019']."</a> |\n
  <a href='#' onclick=\"javascript:setChecked('brisi_poraki','add_check_mark[]',0);return false;\">".$locale['020']."</a> |\n <input type='submit' name='brisi_poraki' value='".$locale['014']."' class='button'></td>\n</tr>\n</table>";
  
 if ($rows > $broj) {echo "<div align='center' style='margin-top:5px;'>\n".makePageNav($rowstart,$broj,$rows,3,"$PHP_SELF?mod=stored&")."\n</div>\n";}
     } else {
 echo "<tr><td colspan='4' width='100%' class='tbl2'>".$locale['018']."</td>\n</tr>\n</table>";
 }
    }

Link to comment
https://forums.phpfreaks.com/topic/97875-select-sorting/
Share on other sites

no no you not undestand me, everything working i just need select option for show ASC and DESC.

 

echo "<div align='left'><select onChange=\"document.form.submit();\" name='sortiraj'><option>Select</option><option value='ASC'>ASC</option><option value='DESC'>DESC</option></select></div>";

 

just need when select ASC get from datebase ASC first.

Link to comment
https://forums.phpfreaks.com/topic/97875-select-sorting/#findComment-501391
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.