Terhox
|
| Posted: 05/16/2005, 12:21 AM |
|
I have following list of menu items for example:
o item 1
o item 2
o item 3
Now I want to reorder them like this (with up/down arrows on admin page):
o item 2
o item 1
o item 3
Which is the best way implementing this in CCS or MySQL?
|
|
|
 |
Uliyr
|
| Posted: 05/16/2005, 11:50 AM |
|
I show you example
----------------------
part of grid
----------------------
<tr>
<td class=""><a class="" href="jobs_pref_list.php?pref_id=50&n=up">up</a> |57| <a class="" href="jobs_pref_list.php?pref_id=50&n=down">down</a></td>
<td class=""><a class="" href="jobs_pref_maint.php?job_pref_id=50">Engineer</a> </td>
</tr>
----------------------
jobs_pref_BeforeSelect
----------------------
//Custom Code @30-1E204A91
// -------------------------
global $jobs_pref;
if ($_SERVER["QUERY_STRING"]) {
if ($_REQUEST["pref_id"] != '' && ($_REQUEST["n"] == 'up' || $_REQUEST["n"] == 'down')) {
$db1 = new clsDBjobs_DB();
$SQL = "select job_pref_id, job_pref_place from jobs_pref where job_pref_id = ".$_REQUEST["pref_id"];
$result = $db1->query($SQL);
if ($db1->next_record()){
$m_id = $db1->f(0);
$m_pl = $db1->f(1);
}
if ($_REQUEST["n"] == 'up') {
$SQL = "select job_pref_id, job_pref_place from jobs_pref where job_pref_place < ".$m_pl." order by job_pref_place DESC limit 1";
}
if ($_REQUEST["n"] == 'down') {
$SQL = "select job_pref_id, job_pref_place from jobs_pref where job_pref_place > ".$m_pl." order by job_pref_place limit 1";
}
$result = $db1->query($SQL);
if ($db1->next_record()){
$c_id = $db1->f(0);
$c_pl = $db1->f(1);
$SQL = "update jobs_pref set job_pref_place = ".$c_pl." where job_pref_id = ".$m_id;
$result = $db1->query($SQL);
$SQL = "update jobs_pref set job_pref_place = ".$m_pl." where job_pref_id = ".$c_id;
$result = $db1->query($SQL);
}
}
}
// -------------------------
|
|
|
 |
Terhox
|
| Posted: 05/17/2005, 11:52 AM |
|
Thank you very much 
I will try it very soon.
|
|
|
 |
|