How can user-selected categories be displayed in user profiles after registration in PHP?
To display user-selected categories in user profiles after registration in PHP, you can store the selected categories in a database table linked to the user's profile. When a user logs in, you can retrieve their selected categories from the database and display them on their profile page.
// Assuming you have a database connection established
// Retrieve user-selected categories from the database
$user_id = $_SESSION['user_id']; // Assuming user is logged in and user_id is stored in session
$query = "SELECT category_name FROM user_categories WHERE user_id = $user_id";
$result = mysqli_query($connection, $query);
// Display the selected categories in the user profile
echo "<h3>Selected Categories:</h3>";
echo "<ul>";
while ($row = mysqli_fetch_assoc($result)) {
echo "<li>" . $row['category_name'] . "</li>";
}
echo "</ul>";