// 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;
}
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 :
";
echo "
| Title Books | Author | Price |
| "; echo $results['id_pdo']; echo " | "; echo $results['nt_pdo']; echo " | "; echo $results['nc_pdo']; echo " |