Hey guys!
I have the following contents in my header.php file and it should only show the contents once because I am not using any loop or no foreach loop at least but it is dispalying liked I am using it:
<?php
include_once 'includes/dbh.php';
$sql = "SELECT * FROM users WHERE user_uid = ?;";
$stmt = mysqli_stmt_init($conn);
if (!mysqli_stmt_prepare($stmt, $sql)) {
header("Location: header.php?index=notexists");
exit();
} else {
mysqli_stmt_bind_param($stmt, "s", $_SESSION['u_uid']);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
while ($row = mysqli_fetch_assoc($result)) {
$sql2 = "SELECT * FROM memberships WHERE user_uid = ?;";
$stmt = mysqli_stmt_init($conn);
if (!mysqli_stmt_prepare($stmt, $sql2)) {
header("Location: header.php?index=notexists");
exit();
} else {
mysqli_stmt_bind_param($stmt, "s", $_SESSION['u_uid']);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
while($row2 = mysqli_fetch_assoc($result)) {
echo '<div class="heading">';
echo '<br></br>';
echo '<br></br>';
echo '<div class="header_title">';
echo '<h1>Welcome to PianoCourse101: '.$row['user_first'].' '.$row['user_last'].'!</h1></div>';
echo '<br></br>';
echo '<h2>Below are your general information. Please feel free to update them in the update section</h2>';
echo '<br></br>';
echo '<h2>Email Address: '.$row['user_email'].'</h2>';
echo '<br></br>';
echo '<h2>User Permission: '.$row['user_permission'].'</h2>';
echo '<br></br>';
echo '<h2>Lesson Subscriptionplan: '.$row2['subscriptionplan'].', '.$row2['subscriptionplan2'].', '.$row2['subscriptionplan3'].'</h2>';
echo '<br></br>';
echo '<h2>Date of Subscription: '.$row['datejoined'].'</h2>';
echo '<br></br>';
echo '<h2>Last Login: '.$row['user_session'].'</h2>';
echo '<br></br>';
echo '</div>';
}
}
}
}
?>
The page currently looks like this: