[eluser]rogierb[/eluser]
Ook, here goes.
Example: arrow down, image[3]
Code:
echo form_open("to the save function");
echo form_hidden("current_record_id" $current_rec_id);
echo form_hidden("other_record_id" $next_rec_id);
echo form hidden("new_order", $old_order + 1);
echo form hidden("ordering", "plus");
echo form_submit("arrow_down","arrow_down");
echo form_close();
Example: arrow up, image[3]
Code:
echo form_open("to the save function");
echo form_hidden("current_record_id" $current_rec_id);
echo form_hidden("other_record_id" $next_rec_id);
echo form hidden("new_order", $old_order - 1);
echo form hidden("ordering", "minus");
echo form_submit("arrow_up","arrow_up");
echo form_close();
Now update both current image and the one that is moved aswell.
So img[3] will have order 2 and img[2] will have order 3 moving img[3] up.
Code:
function save_function()
{
//update current image
$this->db->where("id",$this->input->post("current_record_id"))
$this->db->update("image_table", array("order"=>$this->input->post("order")));
//update other record
"plus" = $this->input->post("ordering") ? $other_order = $this->input->post("order") - 1 : $other_order = $this->input->post("order") +1;
$this->db->where("id",$this->input->post("other_record_id"))
$this->db->update("image_table", array("order"=>$other_order));
}
After saving, reload the page,