electricphp
Programmer
Is there a php script that allows you to visually arrange items in a database by dragging and dropping pictures of the items so they appear in the order you would want them to?
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
$query = "Update items set oid = ? where itemId = ?";
$stmt = $conn->prepare($query);
foreach($_POST['image'] as $imageID=>$order){
$stmt->execute(array($order, $imageID));
if (!($stmt)) {
die ('error'); //can be anything accept OK
}
}
echo 'OK';
<?php
mysql_connect($hostname, $username, $password);
mysql_select_db($database);
$query = "Update images set imageOrder = '%s' where imageID = '%s'";
foreach($_POST['image'] as $imageID=>$order){
$query = sprintf($_query, mysql_real_escape_string($order), mysql_real_escape_string($imageID));
mysql_query($query) or die(mysql_error());
}
echo 'OK';
?>
<form id="form1" name="form1" method="post" action="updateSortOrder.php">
<input name="image" type="hidden" id="image" value="3" />
<input name="image" type="hidden" id="image" value="5" />
<input type="submit" name="Submit" value="Submit" />
</form>
<?php
mysql_connect($hostname, $username, $password);
mysql_select_db($database);
$_query = "Update images set imageOrder = '%s' where imageID = '%s'";
$result = mysql_query($query) or die
foreach($_POST['image'] as $imageID=>$order){
$query = sprintf($_query, mysql_real_escape_string($order), mysql_real_escape_string($imageID));
mysql_query($query) or die(mysql_error());
}
echo 'OK';
?>
$('status').innerHTML = 'Error updating database:<br/>Error was + rT';