hello im doing an app where it manages house owners and tenants connection, im trying to print an apartment id for specific apartment but keeps getting error
this my code:
$user = $_SESSION['username'];
$query="select ID from apartment WHERE owner= '$user'";
$res = mysqli_query($conn,$query);
print_r($res)
im getting this error
"mysqli_result Object ( [current_field] => 0 [field_count] => 1 [lengths] => [num_rows] => 0 [type] => 0 )"
My Answer:
"SELECT apartment_id FROM apartments WHERE owner_username = '$user'";_$result = mysqli_query($conn, $query);_if(mysqli_num_rows($result) > 0) { $row = mysqli_fetch_assoc($result); echo "Apartment ID: " . $row['apartment_id'];} else { echo "No apartment found for this owner";}
Rate this post
5 of 5 based on 1954 votesComments