I'm having some problems inserting a sort into the database, I'm using a Drag and Drop system, which I downloaded on the net and the system works exactly as I need and want.
Only I have a problem to solve, which is to save the system command Drag and Drop in the database.
The idea is this: the client wants a galleries system that drags the photos from the gallery, so that it is in the order he has determined, the drag & drop already does this. I can now retrieve the ID of each image. Now all I need is to determine a type value to make the count from 1 to the amount of images, type: if you have 10 images and the client did the sorting. I need to list the numbers from 1 to 10, and save those numbers in the table, in the order field, so when I list the images on the site I order exactly in order.
I do not know if they could understand, but I'll show the snippet of my code.
<div id="redips-drag">
<?php
$order = filter_input_array(INPUT_POST, FILTER_DEFAULT);
if (isset($order['SelectOrdem']) AND $order['SelectOrdem'] == 'Salvar Ordem'):
unset($order['SelectOrdem']);
endif;
?>
<form action="" method="post">
<table style='width:100%;'>
<colgroup>
<col width="250"/>
<col width="250"/>
<col width="250"/>
<col width="250"/>
</colgroup>
<tbody>
<tr>
<?php
$gbi = 0;
$Gallery = new Read;
$Check = new Check;
$Gallery->ExeRead("ws_posts_gallery", "WHERE post_id = :post", "post={$postid}");
if ($Gallery->getResult()):
$LoopHorizontal = 4;
$i = 1;
foreach ($Gallery->getResult() as $gb):
if ($i < $LoopHorizontal):
$gbi++;
?>
<td>
<div class="redips-drag">
<input type="text" name="ordem[]" value="<?= $gbi; ?>">
<input type="text" name="id[]" value="<?= $gb->gallery_id; ?>">
<?= $Check->Image('../uploads/' . $gb->gallery_image, $gbi, 146, 100); ?><br>
<a href="painel.php?exe=produtos/update&postid=<?= $postid; ?>&gbdel=<?= $gb->gallery_id; ?>#gbfoco" class="del btn btn-danger">Deletar</a>
</div>
</td>
<?php elseif ($i = $LoopHorizontal):
?>
<td>
<div class="redips-drag">
<input type="text" name="ordem[]" value="<?= $gbi; ?>">
<input type="text" name="id[]" value="<?= $gb->gallery_id; ?>">
<?= $Check->Image('../uploads/' . $gb->gallery_image, $gbi, 146, 100); ?><br>
<a href="painel.php?exe=produtos/update&postid=<?= $postid; ?>&gbdel=<?= $gb->gallery_id; ?>#gbfoco" class="del btn btn-danger">Deletar</a>
</div>
</td>
</tr>
<tr>
<?php
$i = 0;
endif;
$i++;
endforeach;
endif;
?>
</tr>
</tbody>
</table>
<div class="form-actions">
<input type="submit" class="btn btn-primary green" value="Salvar Ordem" name="SelectOrdem" />
</div>
</form>
</div>
I do not know folks, if I did it right there, I kind of wrapped the drag & drop in a form, to try to recover the values, but to no avail. If anyone can help with this problem, I'm very grateful!