I have a highlights table and these highlights are displayed as slide show, total number of slides limit with 5. Administration side i can set the priority (1-5) using dropdown. I've around 200 highlights.Except this 5, all others priority will be 0. i need to set the priority number as unique if it is greater than 0. for eg: when i create a new highlight or changing priority of an old highlight as 1, then if any other highlight have priority 1 that must be change to 0 and the new one became at 1st position.
This is my code, can you guys help me to improve this??
if (isset($_POST['update'])) {
$statquery = "UPDATE `highlight_feature` SET `active` = '0'";
$ststresult = mysql_query($statquery) or die(mysql_error());
$query = "SELECT * FROM highlight_feature ORDER BY No DESC";
$result = mysql_query($query) or die(mysql_error());
while ($resultdata = mysql_fetch_array($result)) {
$highlightid = $resultdata['No'];
$status = $_POST[$highlightid];
if ($status > 0) {
$update_Query = "UPDATE `highlight_feature` SET `active` = $status WHERE `No` =$highlightid";
$updateresult = mysql_query($update_Query) or die(mysql_error());
}
}
header("Location: " . $domain . "/highlight/edit/index.php?cat=999");
exit();
}