I have a form in which input fields are displayed via a while loop with but I'm having issues with collecting the data from the input fields to save to the DB. What should be the possible php script to collect the form data?
if(isset($_GET['submit'])){
//collect form data
}
$sql="SELECT * FROM epl";
$result=mysqli_query($db_conx,$sql);
if($nr=mysqli_num_rows($result)>0){
These two variables are initialized as with 1 which is used in the while loop to increase the values will serve as the names of the input fields.
$Inum1=1;
$Inum2=1;
while($row=mysqli_fetch_array($result)){
$t1=$row['team1'];
$t2=$row['team2'];
echo '<form METHOD="get">
<div class="block">
<div class="epl_form_g">
<div class="eplT">
<label >'.$t1.'</label>
</div>
<input type="text" name="t_'.$Inum1.'_score" id="input">
</div>
<label class="vs">vs</label>
<div class="epl_form_g">
<input type="text" name="t_'.$Inum2.'_score" id="input">
<div class="eplT">
<label>'.$t2.'</label>
</div>
</div>
</div> ';
$Inum1++;
$Inum2++;
}
echo ' <center><input name="submit" type="submit" value="ENTER NOW!"
style="width:30%; background-color:#379BFF; text-align:center;border:none; border-radius:3px; height:41px; color:#FFF;
font-size:24px; box-shadow:none; margin-top:20PX;">
</form>';
}