troubleshooting Question

Unwanted output from my query

Avatar of Jazzy 1012
Jazzy 1012 asked on
PHPMySQL Server
5 Comments1 Solution178 ViewsLast Modified:
require "../connection.php";
$result= mysqli_query($conn,"SELECT * FROM Users WHERE email = '$email'");
$row = mysqli_fetch_row($result);
$firstname = $row[1];
$zip = $row[6];

$query="select * from Zip WHERE zip = '$zip'";
$result2 = mysqli_query($conn,$query);
$counter = 0;
while ($row2 = mysqli_fetch_row($result2))
{
	$counter++;
	$ids= $row2[1];

	$query1= "SELECT * from Zones LEFT JOIN both ON Zones.id = both.zone_id LEFT JOIN Windows ON both.window_id = Windows.id where Zones.id = '".$ids ."'";
	$result3 = mysqli_query($conn,$query1);
	$row3 = mysqli_fetch_row($result3);
	$dayt = $row3[9];
	$times = $row3[10];

?>
<form>
<table class="table table-bordered">
<thead>
      <tr>
    <th class="thheader">Monday</th>
    <th class="thheader">Tuesday</th>
    <th class="thheader">Wednesday</th>
    <th class="thheader">Thursday</th>
    <th class="thheader">Friday</th>
    </tr>
    </thead>
    <tr>
      <td>
      <center>
      <?php if($dayt == '1'){ ?>
      	<input type="checkbox" class="colour-button cbb" name="v1" value="10 - 12" id="btn112<?php echo $counter;?>" /><label for="btn112<?php echo $counter;?>"> <i class="fa fa-check-circle hide12" id="chk-btn112<?php echo $counter;?>"></i>  <?php echo $times;?></label>

      <?php }?>
      </center>
      </td>
      <td>
      <center>
      <?php if($dayt == '2'){?>
      <input type="checkbox" class="colour-button cbb1" name="v1" value="10 - 12" id="btn1012<?php echo $counter;?>" /><label for="btn1012<?php echo $counter;?>"> <i class="fa fa-check-circle hide13" id="chk-btn1012<?php echo $counter;?>"></i>  <?php echo $times;?></label>
      <?php }?>  
      </center>
      </td>
      <td>
      <center>
      <?php if($dayt == '3'){?>
      <input type="checkbox" class="colour-button cbb2" name="v1" value="10 - 12" id="btn102<?php echo $counter;?>" /><label for="btn102<?php echo $counter;?>"> <i class="fa fa-check-circle hide14" id="chk-btn102<?php echo $counter;?>"></i>  <?php echo $times;?></label>
      <?php }?>  
      </center>
      </td>
      <td>
      <center>
      <?php if($dayt == '4'){?>
      <input type="checkbox" class="colour-button cbb3" name="v1" value="10 - 12" id="btn1032<?php echo $counter;?>" /><label for="btn1032<?php echo $counter;?>"> <i class="fa fa-check-circle hide15" id="chk-btn1032<?php echo $counter;?>"></i>  <?php echo $times;?></label>
      <?php }?>  
      </center>

      </td>
      <td>
     <center>
      <?php if($dayt == '5'){?>
      <input type="checkbox" class="colour-button cbb4" name="v1" value="10 - 12" id="btn1042<?php echo $counter;?>" /><label for="btn1042<?php echo $counter;?>"> <i class="fa fa-check-circle hide16" id="chk-btn1042<?php echo $counter;?>"></i>  <?php echo $times;?></label>
      <?php }?>  
      </center>
      </td>
    </tr>
    <?php }?>
  </table>
</form>

When I execute it in my database, I get more dates for different days than the my actual output. the $dayt='1' is monday, '2' is tuesday and so on until friday, how can I fix this? My output is in the image
see.png
The real output should be 4 dates on monday not just 1. 3 on wednesday and one on friday
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros