Unwanted output from my query

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>

Open in new window


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
LVL 1
Jazzy 1012Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
Without seeing your data, we're just guessing.  A common approach might be to remove SELECT * and instead SELECT only the columns you want.  SELECT * is an anti-practice, and there is rarely any good reason to use it.  Another common approach is to expand the restrictions of the WHERE clause and add a LIMIT clause.
0
Jazzy 1012Author Commented:
Ok so how do I make the wednesday and friday rows shift up? I dont want it to skip a row everytime
          <?php 
      while ($row3 = mysqli_fetch_assoc($result3))
      {
      	$counter++;
      	$dayt = $row3['day_of_week'];
      	//$times = $row3['time_window_label'];
      	//$tt= explode(",",$times);
      	//print_r($tt[1]);die;?>
    <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 $row3['time_window_label'];?></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 $row3['time_window_label'];?></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 $row3['time_window_label'];?></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 $row3['time_window_label'];?></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 $row3['time_window_label'];?></label>
      <?php }?>  
      </center>
      </td>
    </tr>
    <?php }?>
  </table>
</form>

Open in new window


 

How can I solve this issue?see.png
0
Ray PaseurCommented:
I think what you want may be a two-dimensional matrix.  But I don't have any test data to work with.  If I can find an example from my teaching library I'll come back and post it for you.
1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Jazzy 1012Author Commented:
Can I solve this by making each of a different table but it looks like a whole table above? If so can you show me an example?
0
Jazzy 1012Author Commented:
I took your advice and did a multi-dimension matrix, worked like a charm! Thanks!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.