Having trouble with php and ajax search function
Posted
by
Andy
on Stack Overflow
See other posts from Stack Overflow
or by Andy
Published on 2011-02-23T14:56:15Z
Indexed on
2011/02/23
15:25 UTC
Read the original article
Hit count: 186
I am still quite new to php/ajax/mysql. In anycase, I'm creating a search function which is returning properly the data I'm looking for.
In brief, I have a mysql database set up. A php website that has a search function. I'm now trying to add a link to a mysql database search rather than just showing the results.
In my search.php, the echo line is working fine but the $string .= is not returning anything. I'm just trying to get the same as the echo but with the link to the mysql php record. Am I missing something simple?
//echo $query;
$result = mysqli_query($link, $query);
$string = '';
if($result) {
if(mysqli_affected_rows($link)!=0) {
while($row = mysqli_fetch_array($result,MYSQLI_ASSOC)) {
echo '<p> <b>'.$row['title'].'</b> '.$row['post_ID'].'</p>';
$string .= "<p><a href='set-detail.php?recordID=".$row->post_ID."'>".$row->title."</a></p>";
}
} else {
echo 'No Results for :"'.$_GET['keyword'].'"';
}
© Stack Overflow or respective owner