I am trying to query a mysql table using some "likes". But it doesn't work at all.
This is my code:
$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>";
}
}
Thanks!
mysql_query()mysql_*functions. The extension is outdated and has been superceeded by MySQLi and PDO_mysql. The PHP development team have begun the deprecation process for the stock mysql extension and it will be removed from PHP in a future version (hopefully the not-too-distant future).