0
I’m looking for a contract at the bank, but when I click on Submit nothing is returned:
Follow the code below:
class Config{
// specify your own database credentials
private $host = "localhost";
private $db_name = "biodata";
private $username = "root";
private $password = "";
public $conn;
// get the database connection
public function getConnection(){
$this->conn = null;
try{
$this->conn = new PDO("mysql:host=" . $this->host . ";dbname=" . $this->db_name, $this->username, $this->password);
}catch(PDOException $exception){
echo "Connection error: " . $exception->getMessage();
}
return $this->conn;
}
} ?>
<?php
// Search from MySQL database table
$search= isset($_POST['search']) ? $_POST['search'] : '';
$query = $db->prepare("select from crudpdo2 where nt_pdo LIKE '%$search%' ORDER BY id_pdo");
$query->bindValue(1, "%$search%", PDO::PARAM_STR);
$query->execute();
// Display search result
if (!$query->rowCount() == 0) {
echo "Search found :<br/>";
echo "<table style=\"font-family:arial;color:#333333;\">";
echo "<tr><td style=\"border-style:solid;border-width:1px;border-color:#98bf21;background:#98bf21;\">Title Books</td><td style=\"border-style:solid;border-width:1px;border-color:#98bf21;background:#98bf21;\">Author</td><td style=\"border-style:solid;border-width:1px;border-color:#98bf21;background:#98bf21;\">Price</td></tr>";
while ($results = $query->fetch()) {
echo "<tr><td style=\"border-style:solid;border-width:1px;border-color:#98bf21;\">";
echo $results['id_pdo'];
echo "</td><td style=\"border-style:solid;border-width:1px;border-color:#98bf21;\">";
echo $results['nt_pdo'];
echo "</td><td style=\"border-style:solid;border-width:1px;border-color:#98bf21;\">";
echo $results['nc_pdo'];
echo "</td></tr>";
}
echo "</table>";
} else {
echo 'Nothing found';
}
?>
I could not understand much the code, but I’ve seen a small error, usually this is done in separate files, one with the search form and the other with the mechanics. The error must be because Voce has the Submit button but has no form for this button, in case it should have a form with action="#"
– Leonardo
I think you now agree with what you told me, but still it was not, thank you for the attention.
– user3275937