我正在尝试使用一些“喜欢”来查询 mysql 表。但它根本不起作用。
这是我的代码:
$color_base1 = $row[color_base1];
$color_base2 = $row[color_base2];
$result2 = mysql_query("SELECT * FROM item_descr WHERE (color_base1 LIKE
'%$color_base1%' OR color_base2 LIKE '%$color_base1%' OR color_base1
LIKE '%$color_base2%' OR color_base2 LIKE '%$color_base2%')
AND id_item != $itemId");
if (mysql_fetch_array($result2) == 0)
{
$result2 = mysql_query("SELECT * FROM item_descr WHERE (keywords LIKE
'%$keywords%') AND id_item != $itemId LIMIT 3");
}
else
{
$row2 = mysql_fetch_array($result2);
echo "<div class='similarTitle'>YOU MAY ALSO LIKE</div>";
while ($row2 = mysql_fetch_array($result2))
{
echo "<div class='similarItems'>";
echo "<img class='similarImage' src='images/{$row2[thumb1]}.jpg'>";
echo "<div class='similarItemsText'>".$row2[name]."</div></div>";
}
}
谢谢!