I am trying to figure out how to modify this section of code to make the featured listings random. I tried a couple of variations but I keep getting errors
Code:
// Add ORDER BY and LIMIT functions into the SQL
$sql2 = $sql;
// Make all featured listings come first
$sql2.= ' ORDER BY ';
if (!isset($search['seed']))
$search['seed'] = 0;
if (isset($search['order_by']) && $search['order_by'] != 'ANY' &&
($search['order_by'] == 'price' ||
$search['order_by'] == 'date_added' || $search['order_by'] == 'bedrooms' ||
$search['order_by'] == 'bathrooms'))
$sql2.= ' ' . $search['order_by'] . ' ';
else
$sql2.= ' featured, RAND(' . $search['seed'] . ') ';
if (isset($search['order_by']) && $search['order_by'] != 'ANY'
&& isset($search['order_by_type']) && $search['order_by_type'] != 'ANY' &&
($search['order_by_type'] == 'DESC' || $search['order_by_type'] == 'ASC' ))
$sql2.= $search['order_by_type'];
$sql2.= ' LIMIT ' . $results_page . ', ' . $conf['search_results'];
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'featured, RAND(0) LIMIT 0, 12' at line 1