$nextpubdate) { $pubdates[] = date('Y-m-d', strtotime($row['pubdate'])); } // $pubdates[] = date('Y-m-d', strtotime($row['pubdate'])); } $pubdate = ($_GET['pd']) ? $_GET['pd'] : date('Y-m-d', strtotime("last friday")); $query = 'select l.id, l.mapno, l.address, l.branch_id, b.office_id_fk, l.fsbo_phone, l.hostedby from ohs_listing l left join ohs_office_branch b on l.branch_id = b.id where pubdate = \'' . $pubdate . '\' order by mapno'; if (!($res = mysql_query($query, $conn))) showerror(); while ($row = mysql_fetch_assoc($res)) { extract($row); $office_id_fk = ($office_id_fk) ? $office_id_fk : 0; $listings[$mapno] = array($id, $address, $office_id_fk, $fsbo_phone, $hostedby); $branch_ids[] = $office_id_fk; foreach(explode(',', $hostedby) as $host) { if ($host) { $hosts[] = $host; } } } if ($hosts) { $hosts = array_unique($hosts); $query = 'select id, h_name, h_phone from ohs_hosts where id in (' . implode(', ', $hosts) . ')'; $hosts = array(); if (!($res = mysql_query($query, $conn))) showerror(); while ($row = mysql_fetch_assoc($res)) { extract($row); $hosts[$id] = array($h_name, $h_phone); } } sort($branch_ids); $query = 'select b.office_id_fk id, o.o_name from ohs_office o, ohs_office_branch b where o.id = b.office_id_fk and o.id in (' . implode(', ', array_unique($branch_ids)) . ')'; if (!($res = mysql_query($query, $conn))) showerror(); while ($row = mysql_fetch_assoc($res)) { extract($row); $offices[$id] = $o_name; } if (count($pubdates) == '1') { $dateMenu = '' . date('F j', strtotime($pubdates[0])) . ''; } else { $dateMenu = '' . "\n"; } ?>