Hi
I am making a search form where the admin can search for a name using a input field and returns the results for records that match the name, that side of it works but I can't get the id record number retrieved from the db and make it a clickable link but I get the following error in the id column
Notice: Trying to get property of non-object in /home/firstqualityfina/public_html/admin/unsecured-loan-applicants/search-unsecured-loan-applicant-results.php on line 97
On line 97 is the following
echo "<a href='view-specific-unsecured-loan-applicant.php?id=" . $results->id ."'>".$results->id . "</a>";
The whole code looks like the following
<?php //load database connection $host = "localhost"; $user = ""; $password = ""; $database_name = ""; $pdo = new PDO("mysql:host=$host;dbname=$database_name", $user, $password, array( PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION )); // Search from MySQL database table $search=$_POST['search']; $query = $pdo->prepare("select id, fullname, address, emailaddress, phonenumber, mobilenumber, amountloan, term, homeowner, DATE_FORMAT(loanappdate, '%d/%m/%Y') AS 'loanappdate' from unsecured_loans where fullname LIKE '%$search%' LIMIT 0 , 10"); $query->bindValue(1, "%$search%", PDO::PARAM_STR); $query->execute(); $query->execute(); // Display search result if (!$query->rowCount() == 0) { echo "<div style='clear: both;'>"; echo "<br><br>"; echo "<table class='records'>"; echo "<thead>"; echo "<tr>"; echo "<th>ID</th>"; echo "<th>Full Name</th>"; echo "<th>Address</th>"; echo "<th>Email Address</th>"; echo "<th>Phone Number</th>"; echo "<th>Mobile Number</th>"; echo "<th>Unsecured Loan Amount</th>"; echo "<th>Term(Months)</th>"; echo "<th>Applicant Status</th>"; echo "<th>Unsecured Loan Application Date</th>"; echo "<th>Actions</th>"; echo "</tr>"; echo "</thead>"; while ($results = $query->fetch()) { echo "<tr><td>"; echo "<a href='view-specific-unsecured-loan-applicant.php?id=" . $results->id ."'>".$results->id . "</a>"; echo "</td><td>"; echo $results['fullname']; echo "</td><td>"; echo $results['address']; echo "</td><td>"; echo $results['emailaddress']; echo "</td><td>"; echo $results['phonenumber']; echo "</td><td>"; echo $results['mobilenumber']; echo "</td><td>"; echo '£' . $results['amountloan']; echo "</td><td>"; echo $results['term']; echo "</td><td>"; echo $results['homeowner']; echo "</td><td>"; echo date("d/m/Y", strtotime($results['loanappdate'])); echo "</td><td>"; echo '<a onClick=\"javascript: return confirm("Are you sure you wish to delete this applicant?");\" href="delete.php?id=<?= $row["id"]; ?>">Delete</a></td>'; echo "</tr>"; echo "</table>"; } } ?>
Thank you in advance