我寫了允許我使用mysql獲取信息的代碼,這是舊代碼,我嘗試從mysql更改爲mysqli,但有些如何工作不正確,我相信我仍然新的瞭解mysqli的,任何一個可以幫我寫成從MySQL的mysqli這樣我就可以從那裏瞭解自己請...這裏是代碼...從mysql更改爲mysqli
感謝...
<?php
include('db.php');
?>
<?php
if(isset($_POST['kw']) && $_POST['kw'] != '')
{
$kws = $_POST['kw'];
$kws = mysql_real_escape_string($kws);
$query = "select * from product where product_name like '%".$kws."%' limit 10" ;
$res = mysql_query($query);
$count = mysql_num_rows($res);
$i = 0;
if($count > 0)
{
echo "<ul>";
while($row = mysql_fetch_array($res))
{
echo "<a href='$row[product_name]'><li>";
echo "<div id='rest'>";
echo $row['product_name'];
echo "<br />";
echo "<td>";?><img src="<?php echo $row["screenshot"];?>" height="100" width="100" <?php echo "</td>" ;
echo "</div>";
echo "<div style='clear:both;'></div></li></a>";
$i++;
if($i == 5) break;
}
echo "</ul>";
if($count > 5)
{
echo "<div id='view_more'><a href='#'>View more results</a></div>";
}
}
else
{
echo "<div id='no_result'>No result found !</div>";
}
}
?>
它幾乎相同。只要查看與mysql相同的mysqli函數,並看到它們需要鏈接參數。 – AbraCadaver