Jump to content

LEFT JOIN data not displayed?


rocky48

Recommended Posts

I am trying to write some code to display the visits to my site each week in batches of 13 weeks (1 quarter).

I am getting the Week No and the number of hits, but the actual date, which is in a separate table is not being displayed.

I have tried LEFT JOIN and INNER Join and even RIGHT JOIN (this only displays the Date).

I can't see where I am going wrong!

Here is the code:

<?
include('connect_visits.php');
doDB7();
$limitStart = $_POST['QUARTER'] - 13;
$Visit_data="SELECT Visits.ID, Visits.WVisits, Visits.WCom, WeekNo.WNo, WeekNo.WCom
        FROM Visits 
        LEFT JOIN WeekNo
            ON Visits.ID = WeekNo.WCom
        ORDER BY Visits.ID
	 LIMIT {$limitStart}, 13";
$Visit_data_res = mysqli_query($mysqli, $Visit_data) or die(mysqli_error($mysqli));
$display_block = "
<table width=\"20%\" cellpadding=\"3\" cellspacing=\"1\" border=\"1\" BGCOLOR=\"white\" >
	<tr>
	<th>Week No</th>
	<th>Week Commencing</th>
	<th>Visits</th>
		</tr>";	
while ($C_info = mysqli_fetch_array($Visit_data_res)) {
		$Cid = $C_info['ID'];
		$Visits = ($C_info['WVisits']);
		$WeekNo = ($C_info['WCom']);
//add to display
$display_block .= "
<tr>
<td width=\"1%\" valign=\"top\">".$Cid."<br/></td>
<td width=\"8%\" valign=\"top\">".$WeekNo."<br/></td>
<td width=\"5%\" valign=\"top\">".$Visits."<br/></td>
</td></tr>";
}
mysqli_free_result($Visit_data_res);
?>

Where am I going wrong?

Link to comment
https://forums.phpfreaks.com/topic/293500-left-join-data-not-displayed/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.