added priority
This commit is contained in:
16
add_item.php
16
add_item.php
@@ -10,6 +10,7 @@ $ItemPrice = $_POST['ItemPrice'];
|
||||
$ItemLink = $_POST['ItemLink'];
|
||||
$ItemImage = $_POST['ItemImage'];
|
||||
$ListID = $_POST['ItemListID'];
|
||||
$nextPriority = 0;
|
||||
|
||||
#--- check if the provided Link is a valid URL
|
||||
|
||||
@@ -42,13 +43,20 @@ if ($conn->connect_error) {
|
||||
die('Connection failed: ' . $conn->connect_error);
|
||||
}
|
||||
|
||||
$stmt = $conn->prepare('INSERT INTO whishes (title, description, link, image, price, whislist) VALUES (?, ?, ?, ?, ?, ?)');
|
||||
$stmt = 'SELECT MAX( priority ) AS maxprio FROM whishes WHERE whislist = ' . $ListID . ';';
|
||||
$result = $conn->query($stmt);
|
||||
|
||||
if (false === $stmt) {
|
||||
die('prepare() failed: ' . htmlspecialchars($mysqli->error));
|
||||
while ($row = mysqli_fetch_array($result)) {
|
||||
$nextPriority = $row['maxprio'] + 1;
|
||||
}
|
||||
|
||||
$rc = $stmt->bind_param('ssssii', $ItemTitle, $ItemDescription, $ItemLink, $imageLocalLink, $ItemPriceCents, $ListID);
|
||||
$stmt = $conn->prepare('INSERT INTO whishes (title, description, link, image, price, whislist, priority) VALUES (?, ?, ?, ?, ?, ?, ?)');
|
||||
|
||||
if (false === $stmt) {
|
||||
die('prepare() failed: ' . htmlspecialchars($conn->error));
|
||||
}
|
||||
|
||||
$rc = $stmt->bind_param('ssssiii', $ItemTitle, $ItemDescription, $ItemLink, $imageLocalLink, $ItemPriceCents, $ListID, $nextPriority);
|
||||
if (false === $rc) {
|
||||
die('bind_param() failed: ' . htmlspecialchars($stmt->error));
|
||||
}
|
||||
|
Reference in New Issue
Block a user