<?php
function addnews($message, $order, $active) {
$message = mysql_real_escape_string($message);
$order = mysql_real_escape_string($order);
if (orderexists($order, $active) === true) {
$pass = orderrenum($order, $active);
}
$sql = "INSERT INTO news VALUES ('','$message', '$order', '1')";
$result = mysql_query($sql);
mysql_close();
if (!empty($result)) {
return true;
} else {
return $result;
}
}
function orderexists($order, $active) {
$sql = "SELECT order FROM news WHERE order= " . $order . " AND active = 1";
$result = mysql_query($sql);
$num = mysql_numrows($result);
if ($num > 0) {
return true;
} else {
return false;
}
}
function orderrenum($order, $active) {
$sql = "SELECT id, order FROM news WHERE order >= " . $order . " AND active = 1";
$result = mysql_query($sql);
while ($row = mysql_fetch_assoc($result)) {
$sql = "UPDATE news SET order = " . $row['order']+1 . " WHERE id = " . $row['id'];
$result = mysql_query($sql);
}
}
?>
Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
Connect with Certified Experts to gain insight and support on specific technology challenges including:
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE