<?php
  $query = "SELECT * FROM punchsys_section ORDER BY id";
  $result = mysqli_query($conn,$query);
  $num = mysqli_num_rows($result);
  if($num>0){
  while($myrow = mysqli_fetch_array($result)){
  
    $tid = $myrow["id"];
    $tname = $myrow["name"];
	$arrSection[$tid] = $tname;
  
    $i++;
  }
  }
?>

<style>
  .mytable{
    font-size:16px;
	width:700px;
	margin-top:10px;
	color:#FFFFFF;
  }
  
  .mytableth{
    background-color:#000000;
	color:#FFCC00;
	padding:5px 5px 5px 5px;
  }
  
  .mybtn{
    width:100px;
	font-size:14px;
	font-weight: bold;
	font-family: Arial;
  }
    
  .mytext{
    text-align: center;
    padding: 3px;
  }
</style>


<center>
<form action="syssecup.php" method="post">
<table width="300px" cellpadding="0" cellspacing="1" border="0" class="mytable">
  <tr bgColor="#999999" style="color: #EEEEEE" align="center">
    <th class="mytableth">ID</th>
    <th class="mytableth">SECTION</th>
    <th class="mytableth">TIME</th>
  </tr>
<?php
  $i=0;
  foreach($arrSection as $tid=>$tname){
    if( ($i%2)==0 ){
	  $tcolor = "#EEEEEE";
	}else{
	  $tcolor = "#DDDDDD";
	}
	$txtName = "arrSec[$tid]";
?>
  <tr valign="middle" align="center">
    <th class="mytableth" width="100px"><?= $tid ?></td>
    <td bgColor="<?= $tcolor ?>" ><input type="text" name="<?= $txtName ?>" value="<?= $tname ?>" class="mytext" /></td>
    <td bgColor="<?= $tcolor ?>" ><input type="button" value="SHOW TIME" class="mybtn" style="color: #0000FF" onClick="frmSubmit('<?= $tid ?>')"></td>
  </tr>
<?php
    $i++;
  }
?>
  <tr align="center">
    <th class="mytableth" colspan="3"><input type="submit" value="UPDATE" class="mybtn"  style="color: #0000FF" /></th>
  </tr>
</table>
</form>
</center>

<form id="frmSect" action="main.php" method="GET">
    <input type="hidden" name="pg" value="sys">
    <input type="hidden" name="ac" value="sect">
    <input type="hidden" id="hsecid" name="sid" value="">
</form>

<script>
  function frmSubmit(pid){
      document.getElementById("hsecid").value = pid;
      document.getElementById("frmSect").submit();
  }
</script>