Ok i have this code
<?php
include_once ('database_connection.php');
if(isset($_GET['keyword'])){
$keyword = trim($_GET['keyword']) ;
$keyword = mysqli_real_escape_string($dbc, $keyword);
$query = "select name,title,description,link,type from items where name like '%$keyword%' or title like '%$keyword%' or description like '%$keyword%' or link like '%$keyword%' or type like '%$keyword%'";
//echo $query;
$result = mysqli_query($dbc,$query);
if($result){
if(mysqli_affected_rows($dbc)!=0){
$ff = "";
while($row = mysqli_fetch_array($result,MYSQLI_ASSOC)){
$ff .= "<div id='itemdiv2' class='gradient'>";
$ff .= "<div id='imgc'>".'<img src="Images/media/'.$row['name'].'" />'."<br/>";
$ff .= "<a href='#?w=700' id='".$row['id']."' rel='popup' class='poplight'>View full<a/></div>";
$ff .= "<div id='pdiva'>"."<p id='ittitle'>".$row['title']."</p>";
$ff .= "<p id='itdes'>".$row['description']."</p>";
$ff .= "<a href='".$row['link']."'>".$row['link']."</a>";
$ff .= "</div>"."</div>";
echo $ff;
}
}else {
echo 'No Results for :"'.$_GET['keyword'].'"';
}
}
}else {
echo 'Parameter Missing';
}
?>
and i got this error "Notice: Undefined index: id in C:\xampp\htdocs\madeinusa\search.php on line 20" and this is the line 20: "$ff .= "View full";" and i dont know what seems the problem is. i think there is actually problem with the query or in displaying the records scheme. hope someone could help, im open on any suggestions and recommendations. thanks in advance.
That is just a notice that you are missing the id
value from $row
array since you didn't include it in your select
try adding id
in select query:
$query = "select id,name,title,description,link,type from items where name like '%$keyword%' or title like '%$keyword%' or description like '%$keyword%' or link like '%$keyword%' or type like '%$keyword%'";
and it should work
You should mention the id
column in your select query
$query = "select id, name,title,description,link,type from items...
I think your error is here:
$row['id']
You don't select id
in your query. Change it to:
select id,name,title,description,link,type from items where ...