I am new to php/mysql and need some help.
I want to amend some existing code which is used in a search page so that it can calculate each items distance from the user.
I have summarised the existing code below :
Firstly, the code checks to see if there are any items which meet the users query.
Code: Select all
$plf_items = $db->get_sql_number("SELECT a.unit_id FROM " . DB_PREFIX . "units a " . $where_query . " GROUP BY a.unit_id");The code then puts the relevant items into an array.
Code: Select all
if ($plf_items)
{
$sql_select_items = $db->query("SELECT a.item_id, a.name, a.price, a.currency, a.item_location
FROM
" . DB_PREFIX . "items a " . $force_index . "
" . $where_query . "
GROUP BY a.item_id
ORDER BY " . $order_field . " " . $order_type . " LIMIT " . $start . ", " . $limit);
}
Code: Select all
while ($item_details = $db->fetch_array($sql_select_items))
{
<snip>
}
My initial thoughts were to call the function within a while loop with come kind of $t++ counter variable, but I am not sure of the precise code.
Many thanks
EJ