I have a left join, code shown below that takes,
- id
- referrer
- search term
- client_id
From table 1 and then takes the following columns from table 2 using the left join query underneath.
- client_id
- visit_id
- timedate
url1
$query = "SELECT table1.id, table1.search_term, table1.referrer, table1.client_id, table2.client_id, table2.url1, table2.visit_id, table2.timedate ". "FROM table1 LEFT JOIN table2 " "ON table1.id = table2.visit_id WHERE table1.ip_address = '$ip_address' AND table1.client_id='$client_id' Group BY visit_id, timedate"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)){ ?> <div id=''> <?php "<br />"; echo $row['referrer']. " - ". $row['search_term']; echo $row['timedate']. " - ". $row['url1']. " - ". $row['visit_id']; echo "<br />"; ?> </div> <?php }
What I am trying to do is format the rows so the referrer and search term only shows once and not on every line so that the results would look like this.
Referrer Search term
timedate url1 1 timedate Url1 1 timedate url1 1
referrer Search Term
timedate Url1 2 timedate Url1 2 timedate Url1 2
the numbers 1 and 2 are to represent different visit id's by which the results are grouped. At the moment i get the referrer and search term after every row because it is in the loop and understand that. Just don't know if i can show the referrer and searc term just once per group of results.