Ok well what I'd recommend is a little restructure. Also your query quotes are a little messed up so I'll fix that for you, which may resolve your issue of getting a null result too.
As it appears that you are only expecting one row, the while loop needn't be used. Try the following:
PHP Code:
$sql = "SELECT privlinkid, datepaid FROM property INNER JOIN invoice ON invoice.id = property.id WHERE property.id = '{$id}'"; //Capitalising the query's commands is a good practise because it helps your eyes separate the commands from the other stuff. Also, if the ID is an integer, remove the single quotes around it and cast the id to an integer before the query using: $id = (int)$id; - this will prevent SQL injection attacks if you haven't prevented them beforehand.
$result = mysqli_query($link, $sql);
if($result === false){
$error = 'Error - Please enter a valid Property ID. ' . mysqli_error($link);
include 'error.html.php';
exit;
}
$fetch = mysqli_fetch_array($result);
if($fetch === false){ //The first row is false, therefore non-existent, therefore no rows have been returned. Look into the fetch_array function to see why this works.
//do whatever you need to do if no results are returned:
}else{
$privlink = $fetch['privlinkid'];
$paid = $fetch['datepaid'];
echo '<ul>';
echo '<li>Paid: ' . $paid . '</li>'; //exclamation marks are fun and all, but not generally appropriate.
echo '<li>PrivlinkID: ' . $privlink . '</li>';
echo '</ul>';
}
Bookmarks