| Index
» Projekty
» phpMyEdit
» Fórum
» Buttons up or down to change the position of the record |
 |
lapuella
Založený: 26.06.2008
Príspevky: 4
Zaslal: 2008-06-26 18:42
Návrat hore
Odpovedať s citátom
|
Hello,
Can somebody help me out? I want to change the position of an record in phpmyedit up an down by clicking on an image 'up' or 'down' instead of doing this for each record by clicking the edit button and changing the number of the position by hand. I want such a function to sort/change te position of buttons/pages/links etc on my website. I managed to get the images 'up' and 'down' in phpmyedit ;-), but failed to write a function to do the job.
Is there somebody who tried something like this and succeeded?
Greetings Carola
|
lapuella
Založený: 26.06.2008
Príspevky: 4
Zaslal: 2008-06-29 21:15
Návrat hore
Odpovedať s citátom
|
Hello Doug,
Thank you for sharing your solution.
I don't understand all of it, but it seems like an interesting solution. I don't understand how I can use het concat to make the url. Can I use dummy1 as an variabele? And if so, how?
Is it something like this (this is not working)?
'URL' => '$page?action=increment_up&id=$dummy1',
'URLtarget'=> '_self',
'URLdisp' => '$link',
I am just starting with php and my english is not so well (i am dutch), sorry ;-)
Greetings Carola
|
lapuella
Založený: 26.06.2008
Príspevky: 4
Zaslal: 2008-06-29 22:07
Návrat hore
Odpovedať s citátom
|
Hello Doug,
I am using your solution in an very strange way I think, but it seems to work ;-)
I use two virtual fields, one for the button 'up' and another for the button 'down'.
I found out that $key is the value of the id of that record.
I use the concat not in the right way, but I don't know another solution at this time (remember, i am a beginner in programming ;-).
$opts['fdd']['up'] = array (
'colattrs' => ' align="center"',
'name' => 'Up',
'sql|LF' => 'CONCAT("<img src=\"images/ico_up.gif\" width=\"19\" height=\"19\" border=\"0\" alt=\"Omhoog\">")',
'URL' => '$page?action=increment_up&id=$key',
'URLtarget'=> '_self',
'options' => 'RDVL',
'escape' => false,
'sort' => true
);
$opts['fdd']['down'] = array (
'colattrs' => ' align="center"',
'name' => 'Down',
'sql|LF' => 'CONCAT("<img src=\"images/ico_dows.gif\" width=\"19\" height=\"19\" border=\"0\" alt=\"Omlaag\">")',
'URL' => '$page?action=increment_down&id=$key',
'URLtarget'=> '_self',
'options' => 'RDVL',
'escape' => false,
'sort' => true
);
Maybe I don't need the virtual fields, but I don't know another way to show the buttons up and down with their url ;-)
It looks like this now
Now I hope I can create the function that actually changes the position of the record!
Thanks a lot for pointing me into this direction.
I am curious about your final solution.
Greetings Carola
Naposledy upravil lapuella dňa 2008-06-30 09:37, celkom upravené 3 krát
|
lapuella
Založený: 26.06.2008
Príspevky: 4
Zaslal: 2008-06-29 22:22
Návrat hore
Odpovedať s citátom
|
| doug Napísal: |
That was my final solution. In my project, records are sorted by snum and pnum thus they reorder their positions automatically when the form is reloaded.
| Kód: |
| $opts['sort_field'] = array('snum', 'pnum'); |
|
Hello Doug,
I saw your answer with the link to http://phpvs.com/misc/increment.txt after I posted my last text ;-)
I will look at your solution, thank you very much!
You really helped me ;-)))
Greetings Carola
|
laspina
Založený: 01.10.2004
Príspevky: 13
Zaslal: 2008-07-09 09:20
Návrat hore
Odpovedať s citátom
|
| doug Napísal: |
That was my final solution. In my project, records are sorted by snum and pnum thus they reorder their positions automatically when the form is reloaded.
| Kód: |
| $opts['sort_field'] = array('snum','pnum'); |
|
Doug,
this is a very interesting solution. I have slightly modified your code to get a relative increment :
arrow up updates the position using as value the position of the previous record minus one -
arrow down updates the position using as value the position of the next record plus one.
To achieve this goal I have used this simple query:
SELECT id,snum FROM vs_content1b WHERE 1 ORDER BY snum
What I would like to do is to modify this query with something like:
SELECT id,snum FROM vs_content1b WHERE id IN (...) ORDER BY snum
where the (...) set includes all the displayed records id, (for example, the id resulting from a search query).
Is it possible to get these id?
Thank you,
Alessandra
|
|
Odoslať novú tému
Odpovedať na tému
|
|
|
|