Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP Display MYSQL Results within a loop
    text
    copied!<p>I have a left join, code shown below that takes,</p> <ul> <li>id</li> <li>referrer</li> <li>search term</li> <li>client_id</li> </ul> <p>From table 1 and then takes the following columns from table 2 using the left join query underneath.</p> <ul> <li>client_id</li> <li>visit_id </li> <li>timedate</li> <li><p>url1</p> <pre><code> $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)){ ?&gt; &lt;div id=''&gt; &lt;?php "&lt;br /&gt;"; echo $row['referrer']. " - ". $row['search_term']; echo $row['timedate']. " - ". $row['url1']. " - ". $row['visit_id']; echo "&lt;br /&gt;"; ?&gt; &lt;/div&gt; &lt;?php } </code></pre></li> </ul> <p>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.</p> <p>Referrer Search term</p> <p>timedate url1 1 timedate Url1 1 timedate url1 1</p> <p>referrer Search Term</p> <p>timedate Url1 2 timedate Url1 2 timedate Url1 2</p> <p>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.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload