I am trying to access firstname
by it self. I have the code below put together:
<?php
$sql = "SELECT firstname, lastname FROM guests WHERE option = $option";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
// output data of each row
while($row = mysqli_fetch_assoc($result)) {
echo "You Are " . $row["firstname"]. " " . $row["lastname"]. "<br>";
?>
It gives me You are Bob Testing.
I need to convert them to self variable so I can use them anywhere. Like $row["firstname"] = $firstname;
so then I could echo $firstname;
But it won't work if I use $row["firstname"] = $firstname;
I think the issue is somewhere in how I form the result $result = mysqli_query($conn, $sql);
Can I say something else here so then I could just use say $row["firstname"] = $firstname;
and use like echo $firstname;
? Thanks.