hadiweb.ir
تازه وارد
سلام
دوستایی که وارد هستن لطف کنن ببینن ایراد این کد چیه که نمتونه نتایج رو از دیتابیس استخراج کنه ؟
دوستایی که وارد هستن لطف کنن ببینن ایراد این کد چیه که نمتونه نتایج رو از دیتابیس استخراج کنه ؟
کد:
<?php
$q=$_GET['q'];
//connect to the database
$db=mysql_connect ("localhost", "user", "pass") or die ('I cannot connect to the database because: ' . mysql_error());
//-select the database to use
$mydb=mysql_select_db("date");
//-query the database table
$sql="SELECT item_id,item_title FROM Contacts WHERE feeditems LIKE '%" . $q . "%' ";
//-run the query against the mysql query function
$result=mysql_query($sql);
//-create while loop and loop through result set
while($row=mysql_fetch_array($result)){
$item_title =$row['item_title'];
$item_id=$row['item_id'];
//-display the result of the array
echo "<ul>\n";
echo "<li>" . "<a href=\"search.php?id=$ID\">result</a></li>\n";
echo "</ul>";
}
?>