How can PHP be used to create a system where admins can give ratings to members based on their actions?
To create a system where admins can give ratings to members based on their actions, you can use PHP to create a database structure to store member information and ratings given by admins. Admins can log in to the system, view member profiles, and assign ratings accordingly. The ratings can be stored in the database and displayed on member profiles.
<?php
// Connect to database
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "members_ratings";
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Admin assigns rating to member
$admin_id = 1; // Admin ID
$member_id = 2; // Member ID
$rating = 5; // Rating given by admin
$sql = "INSERT INTO ratings (admin_id, member_id, rating) VALUES ('$admin_id', '$member_id', '$rating')";
if ($conn->query($sql) === TRUE) {
echo "Rating assigned successfully";
} else {
echo "Error assigning rating: " . $conn->error;
}
$conn->close();
?>