Link to home
Start Free TrialLog in
Avatar of Jazzy 1012
Jazzy 1012

asked on

Get value in session when using dynamic information

		
$query1= "SELECT DISTINCT * from Zones LEFT JOIN delivery ON Zones.id = delivery.delivery_zone_id LEFT JOIN Windows ON delivery.delivery_window_id = Windows.id where Zones.id = '".$ids ."'";
$result3 = mysqli_query($conn,$query1);
$counter = 0;
$all= array();
<form method="post" action="../deliveries/index.php">
	<center>
		<div class="tables">
			
				<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>
          <?php
          $available = array();
          while ($row3 = mysqli_fetch_assoc($result3))
          {
              
              $dayt = $row3['day_of_week'];
              $times = $row3['time_window_label'];
              $tt= explode(",",$times);
              $available[$dayt][] = trim($tt[1]);

          }
      for ($x=0; $x<3; $x++)
      {
      	?>
   <tr>
    <td>
     <center>
<?php 
      if($available[1][$x] != ''){ 
      $counter++;?>
      <input type="checkbox" class="colour-button choice1 daypicker1" day="1" name="val1" value="<?php echo @$tt[1]?>" 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 @$available[1][$x];?></label>
      <?php }?>
     </center>
   </td>
   <td>
     <center>
      <?php if($available[2][$x] != ''){
      $counter++;?>
      <input type="checkbox" class="colour-button choice2 daypicker2" day="2" name="val2" value="<?php echo @$tt[1]?>" 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 @$available[2][$x];?></label>
      <?php }?>  
     </center>
   </td>
   <td>
    <center>
      <?php if($available[3][$x] != ''){
      $counter++;?>
      <input type="checkbox" class="colour-button choice3 daypicker3" day="3" name="val3" value="<?php echo @$tt[1]?>" 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 @$available[3][$x];?></label>
      <?php }?>  
    </center>
  </td>
   <td>
    <center>
      <?php if($available[4][$x] != ''){
      $counter++;?>
      <input type="checkbox" class="colour-button choice4 daypicker4" day="4" name="val4" value="<?php echo @$tt[1]?>" 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 @$available[4][$x];?></label>
      <?php }?>  
    </center>
   </td>
   <td>
    <center>
      <?php if($available[5][$x] != ''){
      $counter++;?>
      <input type="checkbox" class="colour-button choice5 daypicker5" day="5" name="val5" value="<?php echo @$tt[1]?>" 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 @$available[5][$x];?></label>
      <?php }?>  
    </center>
   </td>
 </tr>
    <?php }?>
</table>

		</div>
	</center>

<?php 
$query5= "SELECT DISTINCT * from DeliveryZones LEFT JOIN delivery_zones_delivery_windows ON DeliveryZones.id = delivery_zones_delivery_windows.delivery_zone_id LEFT JOIN DeliveryWindows ON delivery_zones_delivery_windows.delivery_window_id = DeliveryWindows.id where DeliveryZones.id = '".$ids ."'";

$result5 = mysqli_query($conn,$query5);
$availabl=array();
while($row5 = mysqli_fetch_assoc($result5))
{
	$days= $row5['day_of_week'];
	$availabl[]= $days;
	$av = array_unique($availabl);
	$min = min($av);
}
foreach ($av as $value){

?>
<center class="cen">

<?php 
if($value == '1'){?>
<div class="startdays" id="day-1" <?=$min!=$value ? 'style="display:none;"' : ''?>>
<?php
if (date('D') == 'Mon'){?>
	
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btn1" disabled/><label for="btn1" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btn1"></i>   <?php echo date('l, F dS', strtotime("+7 days"));?></label>
	<br><br>
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btn2" disabled /><label for="btn2" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btn2"></i>  <?php echo date('l, F dS', strtotime("+14 days"));?></label>
	<br><br>
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btn200" disabled /><label for="btn200" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btn200"></i>  <?php echo date('l, F dS', strtotime("+21 days"));?></label>
	<br><br>
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btn201" disabled /><label for="btn201" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btn201"></i>  <?php echo date('l, F dS', strtotime("+28 days"));?></label>
	<?php }?> 

<?php if (date('D') == 'Tue'){?>
	
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btn3" disabled/><label for="btn3" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btn3"></i>   <?php echo date('l, F dS', strtotime("+6 days"));?></label>
	<br><br>
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btn4" disabled /><label for="btn4" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btn4"></i>  <?php echo date('l, F dS', strtotime("+13 days"));?></label>
	<br><br>
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btn400" disabled /><label for="btn400" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btn400"></i>  <?php echo date('l, F dS', strtotime("+20 days"));?></label>
		<br><br>
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btn401" disabled /><label for="btn401" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btn401"></i>  <?php echo date('l, F dS', strtotime("+27 days"));?></label>
	
	<?php }?>
	

<?php if (date('D') == 'Wed'){?>
	
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btn5" disabled/><label for="btn5" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btn5"></i>   <?php echo date('l, F dS', strtotime("+5 days"));?></label>
	<br><br>
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btn6" disabled /><label for="btn6" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btn6"></i>  <?php echo date('l, F dS', strtotime("+12 days"));?></label>
	<br><br>
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btn600" disabled /><label for="btn600" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btn600"></i>  <?php echo date('l, F dS', strtotime("+19 days"));?></label>
	<br><br>
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btn601" disabled /><label for="btn601" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btn601"></i>  <?php echo date('l, F dS', strtotime("+26 days"));?></label>
	<?php }?>	

<?php if (date('D') == 'Thu'){?>
	
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btn7" disabled/><label for="btn7" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btn7"></i>   <?php echo date('l, F dS', strtotime("+4 days"));?></label>
	<br><br>
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btn8" disabled /><label for="btn8" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btn8"></i>  <?php echo date('l, F dS', strtotime("+11 days"));?></label>
	<br><br>
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btn800" disabled /><label for="btn800" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btn800"></i>  <?php echo date('l, F dS', strtotime("+18 days"));?></label>
	<br><br>
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btn801" disabled /><label for="btn801" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btn801"></i>  <?php echo date('l, F dS', strtotime("+25 days"));?></label>
	
	<?php }?>	
	
<?php if (date('D') == 'Fri'){?>
	
	<input type="checkbox" class="colour-button1"  name="val6" value="value6" id="btn9" disabled/><label for="btn9" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btn9"></i>   <?php echo date('l, F dS', strtotime("+10 days"));?></label>
	<br><br>
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btn10" disabled /><label for="btn10" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btn10"></i>  <?php echo date('l, F dS', strtotime("+17 days"));?></label>
	<br><br>
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btn1011" disabled /><label for="btn1011" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btn1011"></i>  <?php echo date('l, F dS', strtotime("+24 days"));?></label>
	<br><br>
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btn112" disabled /><label for="btn112" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btn112"></i>  <?php echo date('l, F dS', strtotime("+31 days"));?></label>
	
	<?php }?>		

<?php if (date('D') == 'Sat'){?>
	
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btn11" disabled/><label for="btn11" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btn11"></i>   <?php echo date('l, F dS', strtotime("+9 days"));?></label>
	<br><br>
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btn12" disabled /><label for="btn12" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btn12"></i>  <?php echo date('l, F dS', strtotime("+16 days"));?></label>
	<br><br>
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btn122" disabled /><label for="btn122" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btn122"></i>  <?php echo date('l, F dS', strtotime("+23 days"));?></label>
	<br><br>
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btn123" disabled /><label for="btn123" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btn123"></i>  <?php echo date('l, F dS', strtotime("+30 days"));?></label>
	
	<?php }?>	
	
<?php if (date('D') == 'Sun'){?>
	
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btn13" disabled/><label for="btn13" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btn13"></i>   <?php echo date('l, F dS', strtotime("+8 days"));?></label>
	<br><br>
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btn14" disabled /><label for="btn14" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btn14"></i>  <?php echo date('l, F dS', strtotime("+15 days"));?></label>
	<br><br>
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btn114" disabled /><label for="btn114" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btn114"></i>  <?php echo date('l, F dS', strtotime("+22 days"));?></label>
		<br><br>
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btn144" disabled /><label for="btn144" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btn144"></i>  <?php echo date('l, F dS', strtotime("+29 days"));?></label>
	<?php }?>
</div>			
<?php }?>


<?php 
if($value == '2'){?>
<div class="startdays" id="day-2" <?=$min!=$value ? 'style="display:none;"' : ''?>>   
    <?php
if (date('D') == 'Mon'){?>
	
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btn15" disabled/><label for="btn15" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btn15"></i>   <?php echo date('l, F dS', strtotime("+8 days"));?></label>
	<br><br>
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btn16" disabled /><label for="btn16" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btn16"></i>  <?php echo date('l, F dS', strtotime("+15 days"));?></label>
	<br><br>
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btnaa" disabled /><label for="btnaa" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btnaa"></i>  <?php echo date('l, F dS', strtotime("+22 days"));?></label>
	<br><br>
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btnab" disabled /><label for="btnab" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btnab"></i>  <?php echo date('l, F dS', strtotime("+29 days"));?></label>
	
	<?php }?>

<?php if (date('D') == 'Tue'){?>
	
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btn17" disabled/><label for="btn17" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btn17"></i>   <?php echo date('l, F dS', strtotime("+7 days"));?></label>
	<br><br>
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btn18" disabled /><label for="btn18" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btn18"></i>  <?php echo date('l, F dS', strtotime("+14 days"));?></label>
	<br><br>
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btnac" disabled /><label for="btnac" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btnac"></i>  <?php echo date('l, F dS', strtotime("+21 days"));?></label>
<br><br>
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btnad" disabled /><label for="btnad" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btnad"></i>  <?php echo date('l, F dS', strtotime("+28 days"));?></label>
	
	
	<?php }?>
	

<?php if (date('D') == 'Wed'){?>
	
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btn19" disabled/><label for="btn19" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btn19"></i>   <?php echo date('l, F dS', strtotime("+6 days"));?></label>
	<br><br>
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btn20" disabled /><label for="btn20" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btn20"></i>  <?php echo date('l, F dS', strtotime("+13 days"));?></label>
	<br><br>
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btnae" disabled /><label for="btnae" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btnae"></i>  <?php echo date('l, F dS', strtotime("+20 days"));?></label>
	<br><br>
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btnaf" disabled /><label for="btaf" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btnaf"></i>  <?php echo date('l, F dS', strtotime("+27 days"));?></label>
	
	<?php }?>	

<?php if (date('D') == 'Thu'){?>
	
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btn21" disabled/><label for="btn21" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btn21"></i>   <?php echo date('l, F dS', strtotime("+5 days"));?></label>
	<br><br>
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btn22" disabled /><label for="btn22" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btn22"></i>  <?php echo date('l, F dS', strtotime("+12 days"));?></label>
	<br><br>
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btnag" disabled /><label for="btnag" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btnag"></i>  <?php echo date('l, F dS', strtotime("+19 days"));?></label>
	<br><br>
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btnah" disabled /><label for="btnah" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btnah"></i>  <?php echo date('l, F dS', strtotime("+26 days"));?></label>
	
	<?php }?>	
	
<?php if (date('D') == 'Fri'){?>
	
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btn23" disabled/><label for="btn23" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btn23"></i>   <?php echo date('l, F dS', strtotime("+11 days"));?></label>
	<br><br>
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btn24" disabled /><label for="btn24" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btn24"></i>  <?php echo date('l, F dS', strtotime("+18 days"));?></label>
	<br><br>
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btnai" disabled /><label for="btnai" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btnai"></i>  <?php echo date('l, F dS', strtotime("+25 days"));?></label>
	<br><br>
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btnaj" disabled /><label for="btnaj" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btnaj"></i>  <?php echo date('l, F dS', strtotime("+32 days"));?></label>
	
	<?php }?>		

<?php if (date('D') == 'Sat'){?>
	
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btn25" disabled/><label for="btn25" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btn25"></i>   <?php echo date('l, F dS', strtotime("+10 days"));?></label>
	<br><br>
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btn26" disabled /><label for="btn26" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btn26"></i>  <?php echo date('l, F dS', strtotime("+17 days"));?></label>
	<br><br>
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btnak" disabled /><label for="btnak" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btnak"></i>  <?php echo date('l, F dS', strtotime("+24 days"));?></label>
	<br><br>
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btnal" disabled /><label for="btnal" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btnal"></i>  <?php echo date('l, F dS', strtotime("+31 days"));?></label>
	
	<?php }?>	
	
<?php if (date('D') == 'Sun'){?>
	
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btn27" disabled/><label for="btn27" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btn27"></i>   <?php echo date('l, F dS', strtotime("+9 days"));?></label>
	<br><br>
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btn28" disabled /><label for="btn28" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btn28"></i>  <?php echo date('l, F dS', strtotime("+16 days"));?></label>
	<br><br>
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btnam" disabled /><label for="btnam" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btnam"></i>  <?php echo date('l, F dS', strtotime("+23 days"));?></label>
<br><br>
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btnan" disabled /><label for="btnan" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btnan"></i>  <?php echo date('l, F dS', strtotime("+30 days"));?></label>
	<?php }?>	
</div>		
<?php }
?>	
</center>
<?php }?>
	<center class="cen">
		<button  class="disabled white cbtn1 c2" type="submit" id="submit" disabled>NEXT &nbsp;&nbsp;&nbsp;<i class="fa fa-long-arrow-right"></i></button>
	</center>
</form>

Open in new window


This is my code, there is more that choses the other days but I only displayed monday and tuesday here. My code allows me to chose one time from monday, tuesday, wed, thurday or friday depending on the time avaliable for me. Then I could only chose one start date at the bottom. I want to be able that when I click the "Next" Button which is the submit, that I can get all my users choses in a session. I tried doing this could on another page:
$value1 = $_POST['val1'];
$value2 = $_POST['val2'];
$value3 = $_POST['val3'];
$value4 = $_POST['val4'];
$value5 = $_POST['val5'];
$value6 = $_POST['val6'];
echo $value1 . $value3; die;

Open in new window

But I just got the first timings even when I chose different ones. In the image is how my code looks like, can anyone help with this gliche?
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Here is how the PHP session works.  TL;DR You must start the session on every page.
https://www.experts-exchange.com/articles/11909/PHP-Sessions-Simpler-Than-You-May-Think.html

This code example will carry the session values from one request to the next, adding information if any of the radio buttons are on.
Please see: https://iconoun.com/demo/temp_jasmine.php
<?php // demo/temp_jasmine.php
/**
 * https://www.experts-exchange.com/questions/29013127/Get-value-in-session-when-using-dynamic-information.html
 */
error_reporting(E_ALL);


// ALWAYS START THE PHP SESSION ON EVERY PAGE, NO EXCEPTIONS
session_start();


// IF THERE IS A POST-METHOD REQUEST
if (!empty($_POST['q']))
{
    // IF THIS IS THE FIRST REQUEST, START THE ARRAY
    if (empty($_SESSION['q'])) $_SESSION['q'] = [];

    // ADD THE POST REQUEST DATA TO THE ARRAY
    $_SESSION['q'][] = $_POST['q'];
}


// IF THERE IS INFORMATION IN THE SESSION
if (!empty($_SESSION)) print_r($_SESSION);


// PREPARE THE HTML DOCUMENT WITH A FORM TO RECEIVE INPUT
$form = <<<EOD
<form method="post">
<input type="radio" name="q" value="A" />A
<input type="radio" name="q" value="B" />B
<input type="radio" name="q" value="C" />C
<br>
<input type="submit" />
</form>
EOD;

echo $form;

Open in new window

Avatar of Jazzy 1012
Jazzy 1012

ASKER

Yes I know this but as you can see I have a for loop at the beginning of my code, therefore what if I click the second time window instead of the first, I should get 9AM-12PM, can you please show me how this is done on my code, because for a normal form and session I am aware of doing it.
Avatar of Julian Hansen
You have a for loop inside which the names of the checkboxes are not changing - if you have a variable number of checkboxes you should make them arrays val1[] val2[] etc

Then when you do this
$val1 = isset($_POST[val1]) ? $_POST[val1] : false;
if ($val1) {
   //$val1 should now be an array of val1 values
}

Open in new window

This may be an issue, too.

<input type="checkbox" class="colour-button1" name="val6" value="value6...

The name appears to be repeated over and over in the HTML document?  Only one value for a given name will appear in the request.

However you can make the name into an array with notation like this:

<input type="checkbox" class="colour-button1" name="val6[]" value="value6...

And you can add information inside the square brackets to further identify the elements of the array.

Is this getting close to being helpful?
I have them the same name, since I only allow the user to chose one per day. So I would only get one value when the form is submitted with that value name
I have the names on purpose so the user can only chose one option.
Can you do a view source of your page and post the HTML
I tried but I couldn't due to the database information, my code is dynamic, nothing will show
Open the page in the browser
Right click the page
Select view source
Copy and paste the HTML from the page here.
		<form method="post" action="../deliveries/index.php">
	<center>
		<div class="tables">
			
				<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>
      <input type="checkbox" class="colour-button choice1 daypicker1" day="1" name="val1" value=" 5AM - 8AM" id="btn1121" /><label for="btn1121"> <i class="fa fa-check-circle hide12" id="chk-btn1121"></i>  5AM - 8AM</label>
           </center>
   </td>
   <td>
     <center>
        
     </center>
   </td>
   <td>
    <center>
            <input type="checkbox" class="colour-button choice3 daypicker3" day="3" name="val3" value=" 5AM - 8AM" id="btn1022" /><label for="btn1022"> <i class="fa fa-check-circle hide14" id="chk-btn1022"></i>  5AM - 8AM</label>
        
    </center>
  </td>
   <td>
    <center>
        
    </center>
   </td>
   <td>
    <center>
            <input type="checkbox" class="colour-button choice5 daypicker5" day="5" name="val5" value=" 5AM - 8AM" id="btn10423" /><label for="btn10423"> <i class="fa fa-check-circle hide16" id="chk-btn10423"></i>  5AM - 8AM</label>
        
    </center>
   </td>
 </tr>
       <tr>
    <td>
     <center>
      <input type="checkbox" class="colour-button choice1 daypicker1" day="1" name="val1" value=" 5AM - 8AM" id="btn1124" /><label for="btn1124"> <i class="fa fa-check-circle hide12" id="chk-btn1124"></i>  9AM - 12PM</label>
           </center>
   </td>
   <td>
     <center>
        
     </center>
   </td>
   <td>
    <center>
            <input type="checkbox" class="colour-button choice3 daypicker3" day="3" name="val3" value=" 5AM - 8AM" id="btn1025" /><label for="btn1025"> <i class="fa fa-check-circle hide14" id="chk-btn1025"></i>  9AM - 12PM</label>
        
    </center>
  </td>
   <td>
    <center>
        
    </center>
   </td>
   <td>
    <center>
        
    </center>
   </td>
 </tr>
       <tr>
    <td>
     <center>
      <input type="checkbox" class="colour-button choice1 daypicker1" day="1" name="val1" value=" 5AM - 8AM" id="btn1126" /><label for="btn1126"> <i class="fa fa-check-circle hide12" id="chk-btn1126"></i>  6PM - 9PM</label>
           </center>
   </td>
   <td>
     <center>
        
     </center>
   </td>
   <td>
    <center>
            <input type="checkbox" class="colour-button choice3 daypicker3" day="3" name="val3" value=" 5AM - 8AM" id="btn1027" /><label for="btn1027"> <i class="fa fa-check-circle hide14" id="chk-btn1027"></i>  6PM - 9PM</label>
        
    </center>
  </td>
   <td>
    <center>
        
    </center>
   </td>
   <td>
    <center>
        
    </center>
   </td>
 </tr>
    </table>

		</div>
	</center>

<center class="cen">

<div class="startdays" id="day-1" >
 

	

	

	
	
	
	<input type="checkbox" class="colour-button1"  name="val6" value="value6" id="btn9" disabled/><label for="btn9" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btn9"></i>   Monday, April 10th</label>
	<br><br>
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btn10" disabled /><label for="btn10" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btn10"></i>  Monday, April 17th</label>
	<br><br>
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btn1011" disabled /><label for="btn1011" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btn1011"></i>  Monday, April 24th</label>
	<br><br>
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btn112" disabled /><label for="btn112" style="position:relative;padding-left:215px;padding-right:215px;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btn112"></i>  Monday, May 01st</label>
	
			

	
	
</div>			


	

		

	



</center>
<center class="cen">



	

<div class="startdays" id="day-3" style="display:none;">

	

	

	
	
	
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btn37" disabled/><label for="btn37" style="position:relative;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btn37"></i>   Wednesday, April 12th</label>
	<br><br>
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btn38" disabled /><label for="btn38" style="position:relative;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btn38"></i>  Wednesday, April 19th</label>
	<br><br>
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btnau" disabled /><label for="btnau" style="position:relative;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btnau"></i>  Wednesday, April 26th</label>
	<br><br>
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btnav" disabled /><label for="btnav" style="position:relative;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btnav"></i>  Wednesday, May 03rd</label>
			

	
	
</div>			
		

	



</center>
<center class="cen">



	

		

	

    <div class="startdays" id="day-5" style="display:none;">

	
	

	
	
	
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btn65" disabled/><label for="btn65" style="position:relative;padding-left:220px;padding-right:220px"><i class="fa fa-check-circle fa-lg hide11" id="chk-btn65"></i>   Friday, April 14th</label>
	<br><br>
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btn66" disabled /><label for="btn66" style="position:relative;padding-left:220px;padding-right:220px"><i class="fa fa-check-circle fa-lg hide11" id="chk-btn66"></i>  Friday, April 21st</label>
	<br><br>
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btnbp" disabled /><label for="btnbp" style="position:relative;padding-left:220px;padding-right:220px"><i class="fa fa-check-circle fa-lg hide11" id="chk-btnbp"></i>  Friday, April 28th</label>
	<br><br>
	<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btncz" disabled /><label for="btncz" style="position:relative;padding-left:220px;padding-right:220px"><i class="fa fa-check-circle fa-lg hide11" id="chk-btncz"></i>  Friday, May 05th</label>
			

	
	
	
</div>		


</center>

	<center class="cen">
		<button  class="disabled white cbtn1 c2" type="submit" id="submit" disabled>NEXT &nbsp;&nbsp;&nbsp;<i class="fa fa-long-arrow-right"></i></button>
	</center>
</form>
</span>
</div>
</div>
</div>
</div>
<div style="margin:1400px;">

</div>
<script src="http://code.jquery.com/jquery.js"></script>
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script>
Array.min = function( array ){
    return Math.min.apply( Math, array );
};

$(document).ready(function() {
var days = new Array();      
	
$(function() {
	  $(".colour-button").click(enable_cb);
	});
	function enable_cb() {
		   if (this.checked) {
		        //this will mean at least one is always checked
		        $("input.colour-button1").prop("disabled", false);
		        $("#chk-" + this.id).show();
		    }
		    else {
		        //in this case, hide the element if you need to, but check for ANY items
		        $("#chk-" + this.id).hide();

		        var day = $(this).attr("day");
	        	if( ($.inArray(day, days) !== -1) ) {
	        		days.splice(days.indexOf(day), 1);
    		        console.log(days);
    		        console.log(Array.min(days));
    		        var minimum = Array.min(days);
    		        $(".startdays").hide();
    		        $("#day-"+minimum).show();
		        }
		        
		        if ($(".colour-button:checked").length == 0) {
		            $("input.colour-button1").attr("disabled", true).prop("checked", false);
		            $('.hide11').hide(); 
		        	 $('#submit').attr('disabled', true).removeClass('orangeBtn23').addClass('disabled'); //disable input
		        }
		    }
		}
$('.colour-button1').click(function () {
	$("#chk-"+this.id).show();
    //check if checkbox is checked
    if ($(this).is(':checked')) {

	$('#submit').removeAttr('disabled').addClass('orangeBtn23').removeClass('disabled'); //enable input

    } 
    else {
    	$("#chk-"+this.id).hide(); 

        if ($('.colour-button1:checked').length == 0){
     	 $('#submit').attr('disabled', true).removeClass('orangeBtn23').addClass('disabled'); //disable input
      	$("#chk-"+this.id).hide(); 
      	(this.id).hide();
      } }


});
  $('.choice1').click(function() {
	  $('.hide12').hide();
    var name = $(this).attr('name');
    $('input[name="'+name+'"]:checked').not(this).prop({checked: false});
    $("#chk-" + this.id).show();
  });

  
	  $('.choice2').click(function() {
		  $('.hide13').hide();
	    var name = $(this).attr('name');
	    $('input[name="'+name+'"]:checked').not(this).prop({checked: false});
	    $("#chk-" + this.id).show();
	  });

	  $('.choice3').click(function() {
		  $('.hide14').hide();
	    var name = $(this).attr('name');
	    $('input[name="'+name+'"]:checked').not(this).prop({checked: false});
	    $("#chk-" + this.id).show();
	  });


	  $('.choice4').click(function() {
		  $('.hide15').hide();
	    var name = $(this).attr('name');
	    $('input[name="'+name+'"]:checked').not(this).prop({checked: false});
	    $("#chk-" + this.id).show();
	  });


	  $('.choice5').click(function() {
		  $('.hide16').hide();
	    var name = $(this).attr('name');
	    $('input[name="'+name+'"]:checked').not(this).prop({checked: false});
	    $("#chk-" + this.id).show();
	  });


	  $('.colour-button1').on('click', function() {
		  $('.hide11').hide();
		    var name = $(this).attr('name');
		    $('input[name="'+name+'"]:checked').not(this).prop({checked: false});
	      $("#chk-" + this.id).show();
	    
	  });
	});
</script>

</body>
</html>

Open in new window

Page seems truncated but never mind I think the key bits are there.

When I send the completed form to a reflect script I get this
Array
(
    [val1] =>  5AM - 8AM
    [val5] =>  5AM - 8AM
    [val3] =>  5AM - 8AM
    [val6] => value6
)

Open in new window


Which values are not coming through?
You can test it here.
I think I see the problem - your values for your checkboxes are all the same irrespective of the text that goes with them

Looking at your code I see this line repeated
<input type="checkbox" class="colour-button choice1 daypicker1" day="1" name="val1" value="<?php echo @$tt[1]?>" 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 @$available[1][$x];?></label>

Open in new window

First problem your id's are not unique - main problem I suspect is the @$tt[1] which you use for each checkbox - is that 1 index meant to be different for each checkbox?
greetings  Jasmine Ikhreishi , , you have the problem in your PHP code to produce this page of LOOP REPEATS with the identical <input> element HTML output to this page, , , ,  , your code might begin to function if it was single use code NOT in a PHP loop, but there are page restrictions that all page code must observe , as has already been mentioned here,   ALL , each and every input MUST have a unique NAME, and, , ,  if an ID is used, then a unique ID, NOT used by any other element on that page. Fortunately, <form> inputs can be Grouped together by an ARRAY indicator (syntax) in the         name="wed1[]"      by adding the brackets  [   ] to the end of the  name.

But in most of your inputs you do make distinctions between the inputs with the same name in other places -
<input type="checkbox" class="colour-button choice1 daypicker1" day="1" name="val1" value=" 5AM - 8AM" id="btn1121" />
<label for="btn1121"> <i class="fa fa-check-circle hide12" id="chk-btn1121"></i>  5AM - 8AM</label>

<input type="checkbox" class="colour-button choice1 daypicker1" day="1" name="val1" value=" 5AM - 8AM" id="btn1124" />
<label for="btn1124"> <i class="fa fa-check-circle hide12" id="chk-btn1124"></i>  9AM - 12PM</label>

Open in new window

you have nearly Identical HTML in these two different checks Except for the   id="btn1121"    and   id="btn1124"
But the thing is, ,  these ID numbers that u make unique with
         <?php echo $counter;?>
may not relate to any DATA names or sections in your PHP FORM process php page for this "pick a time-date" page code submit.

you might could change the first series of check boxes to something like -
// for first TD as a Monday with an Identifier as   fs for first series, and the ID for the DAY as Mon
<input type="checkbox" class="colour-button choice1 daypicker1" day="1" name="fsMon<?php echo $x;?>" value="fsMon<?php echo $x.'-'.@$tt[1]?>" 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 @$available[1][$x];?></label>


// for second TD as a Tuesday with an Identifier as   fs for first series, and the ID for the DAY as Tue
<input type="checkbox" class="colour-button choice2 daypicker2" day="2" name="fsTue<?php echo $x;?>" value="fsTue<?php echo $x.'-'.@$tt[1]?>" 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 @$available[2][$x];?></label>

Open in new window

I placed code in these to make the inputs have a unique name with the name that relates to the data type of that check box, I also added some Identifier text to the value, , which may not be needed, but your values seem to all be the same? also you could use the ARRAY syntax like -
<input type="checkbox" class="colour-button choice1 daypicker1" day="1" name="fsMon[]" value="fsMon<?php echo $x.'-'.@$tt[1]?>" 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 @$available[1][$x];?></label>

Open in new window

but if this is used in a check then I think you will need to add the  "fsMon1-" or some ID text to the value, so you can tell which check sent this, since unchecked checks send no value, so the   fsMon[] array on server may not be there or have a single element.



this next series of checks using -
<input type="checkbox" class="colour-button1" name="val6" value="value6" id="btn37" disabled/><label for="btn37" style="position:relative;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btn37"></i>   Wednesday, April 12th</label>

Open in new window

just can not be useful, because it has just ONE name for all of them, and even worse, it has the same value for all of them.

you might consider ways to group these  val6  checks, and have some sort of value that tells the form process page what times and dates are chosen , maybe
<input type="checkbox" class="colour-button1" name="ssWed2[]" value="ssWed2-4-12" id="btn37" disabled/><label for="btn37" style="position:relative;"><i class="fa fa-check-circle fa-lg hide11" id="chk-btn37"></i>   Wednesday, April 12th</label>

Open in new window

When I chose 9-12 , the array stays at 5-8 for the outcome since it was the first one, can I change this?
the $tt[1] means the second array after it was trimed earlier, it is not the same outcome I get different outcomes like shown on the image, ethier 5-8AM, 9-12AM,... and so on. The line is only repeated for if the day has more than one window time. Lastly, the id are unique, as you can see I added a counter, that increases the number each time, thus making it unique with no matter how many rows I add.
You use $tt[1] for your value for every checkbox - so it is going to render with the same value. It is that simple.
Okay but how can I send it to the other page?
... so the user can only chose one option
https://en.wikipedia.org/wiki/Radio_button
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yes I have and I just changed the. Ode and tried it in a different way for it to work
Ok, so your question was
But I just got the first timings even when I chose different ones. In the image is how my code looks like, can anyone help with this gliche?
And the answer is "because you were using the same value for the checkboxes in the loop"
Trying to understand how the question was not answered.
Okay I understand it now, I thought you were asking what the value was. Yes that is what my results were thanks
You are welcome.