balkan7 Posted March 25, 2008 Share Posted March 25, 2008 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>"; } } Quote Link to comment https://forums.phpfreaks.com/topic/97875-select-sorting/ Share on other sites More sharing options...
MadTechie Posted March 26, 2008 Share Posted March 26, 2008 okay so whats the problem ? what do you need help with ? Quote Link to comment https://forums.phpfreaks.com/topic/97875-select-sorting/#findComment-500852 Share on other sites More sharing options...
balkan7 Posted March 26, 2008 Author Share Posted March 26, 2008 i wanna for this get value: 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>"; Quote Link to comment https://forums.phpfreaks.com/topic/97875-select-sorting/#findComment-500870 Share on other sites More sharing options...
MadTechie Posted March 26, 2008 Share Posted March 26, 2008 just change "sortiraj" to "sort" and if the form is a post change the get's to post! Quote Link to comment https://forums.phpfreaks.com/topic/97875-select-sorting/#findComment-500880 Share on other sites More sharing options...
balkan7 Posted March 26, 2008 Author Share Posted March 26, 2008 i chane but not working select option! i wanna when you select from option load get ASC or DESC, maybe this is wrong -> onChange=\"document.form.submit();\" Quote Link to comment https://forums.phpfreaks.com/topic/97875-select-sorting/#findComment-501210 Share on other sites More sharing options...
MadTechie Posted March 26, 2008 Share Posted March 26, 2008 if the form is not submitting then yes thats the problem try onChange=\"document.brisi_poraki.submit();\" or onChange=\"brisi_poraki.submit();\" Quote Link to comment https://forums.phpfreaks.com/topic/97875-select-sorting/#findComment-501269 Share on other sites More sharing options...
balkan7 Posted March 26, 2008 Author Share Posted March 26, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/97875-select-sorting/#findComment-501391 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.