I'm having trouble creating a variable for the session user. I'm creating a practice boxing website which matches the session user with somebody with the same attributes i.e. weight
<?php
session_start();
include "connection.php";
$id = $_GET["userID"];
$sql = "SELECT * FROM userdetails WHERE userID = '" . $id . "'";
$result = mysqli_query($con, $sql);
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_assoc($result)) {
echo"<div>" .
"<br>First name: " . $row["firstname"] .
"<br>Second name: " . $row["secondname"] .
"<br>Mobile: " . $row["mobile"] .
"<br>Height: " . $row["height"] . "CM" .
"<br>weight: " . $row["weight"] . "KG" .
"<br>Image:<br> <img src=getimage.php?
userID=" . $row["userID"] . "width=100, height=100" .
"<br> You are a match! click below to view events" .
"<br><a href=Events.php?userID=" . $row["userID"] . ">View
Events</a>" .
"</div>";
}
} else {
echo"0 results";
}
$weight = $row['weight'];
?>
This code allows me to collect and display the data of an individual in my table, the $weight = $row['weight']; line puts the weight for the individual into a variable.
I'm unsure on how I get the session users weight into a variable, then how compare the two. i'd imagine i'll need an IF statement. something like:
if ($weight == $sessionusersweight){
echo "you're a match";
}
else{
echo "you're not a match";
}
any help would be appreciated