PHP, SQL : Apache (ports 80 & 443) and MySQL (port 3306) Need to add functionality to
Question:
PHP, SQL : Apache (ports 80 & 443) and MySQL (port 3306)
Need to add functionality to edit and delete review
Example:
$query="DELETE FROM entries WHERE id={$_POST['id']} LIMIT 1";
$r=mysqli_query($conn,$query);
if (mysqli_affected_rows($conn)==1) {
//it worked!
}
$query="UPDATE entries SET name='$name', review='$review' WHERE id={$_POST['id']}";
$r=mysqli_query($conn,$query);
if (mysqli_affected_rows($conn)==1) {
//it worked!
}
Settings for creating MySQL Account:
creds.php
$username = "reviews_system";
$password = "foobar";
$host = "localhost";
$database = "reviews";
$conn = @mysqli_connect($host, $username, $password, $database);
?>
read_reviews.php
Reviews
require("creds.php");
$query = 'SELECT * FROM entries ORDER BY date_entered DESC';
if($r = mysqli_query($conn, $query)) {
while($row = mysqli_fetch_array($r)) {
print "
{$row['name']}
{$row['review']}
";
}
}
mysqli_close($conn);
?>