Jump to content

add error message


nayanm

Recommended Posts

Hi all, I am working on a search script which searches article titles from the table. i have worked out the function, but have not been able to add an error message if the results are zero. my class file has this following function

 

public function search($table){
 
$search=$_GET['search'];
 
if ($this->databaseConnection()) {
$sql="SELECT * FROM $table WHERE title LIKE '%$search%'";         
$q      = $this->db_connection->query($sql) or die("failed!");
 
while($r = $q->fetch(PDO::FETCH_ASSOC)){
$data[]=$r;
}
return $data;
}
}
 
my results page has the following code
 
 
<?php
foreach($crud->search("articles") as $value){
extract($value);
echo <<<show
<p>" <a href="view.php?article_id=$article_id">$title</a> "</p>
<br>
show;
}
?>
 
 
would be highly obliged if anyone can help me out. apologies if this is a stupid question, but i am pretty much an amateur still.
 
regards,
 
Nayan
 
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.