Sorry found another issue, the search form is returning fields that does not even have the text in the database record so really confused why the results are being displayed that does not even have the word in
below is the whole code I have
Code:
<form action="" method="post">
<input type="text" name="search">
<input type="submit" name="submit" value="Search">
</form>
<?php
$servername = 'localhost';
$username = '';
$password = '';
$dbname = '';
$search_value = (isset($_POST['search']));
$con=new mysqli($servername,$username,$password,$dbname);
if($con->connect_error){
echo 'Connection Failed: '.$con->connect_error;
}else{
$sql="select id, software_title, customers_email, DATE_FORMAT(date_purchased, '%d/%m/%Y') AS date_purchased, sent from product_keys_sold where software_title LIKE '%$search_value%' ORDER BY id";
$res=$con->query($sql);
// display records in a table
echo "<table class='records'>";
// set table headers
echo "<tr>
<th>ID</th>
<th>Software Title</th>
<th>Customers Email</th>
<th>Date Purchased</th>
<th>Sent</th>
<th colspan='2'>Actions</th>
</tr>";
while($row=$res->fetch_assoc()){
echo "<tr>";
echo "<td><a href='view-specific-product-key-sold.php?id=" . $row['id'] . "'>".$row['id'] . "</a></td>";
echo '<td>' . $row["software_title"]; '</td>';
echo '<td>' . $row["customers_email"]; '</td>';
echo '<td>' . $row["date_purchased"]; '</td>';
echo '<td>' . $row["sent"]; '</td>';
echo "<td><a href='add-update-keys-sold.php?id=" . $row['id'] . "'>Edit</a></td>";
echo "<td><a href='delete.php?id=" . $row['id'] . "'>Delete</a></td>";
echo "</tr>";
}
echo '</table>';
}
?>
for example I type windows in the search input field and the database records that get returned does not even have the word windows in?
UPDATE:
I think it is to do with the following line cause even if I click search, the last record disappears and only shows the first two records in the db table
Code:
$search_value = (isset($_POST['search']));
Bookmarks