I'm currently trying to create a daily class routine using PHP. Firstly, the site will have a 7-day name, as a check box, and a text box in which users can enter the number of class periods.
When the user submits the form, the code will create another form inside another table (looks like this ). And finally, the user can enter the class name, teacher name, and the code will save it in the database.
But my problem is dynamically creating the table. I cannot figure out how to solve this problem.
Any help would be appreciated.
Below you can see what I have tried so far:
<h1>Form two</h1>
<form action="routine_create_process.php" method="POST">
<h3>How many class period do you want to add?</h3>
<input type="text" name="period"/>
<h3>Avalible class day</h3>
<label><input type="checkbox" name="f[]" value="sat" /> Saturday </label>
<br />
<label><input type="checkbox" name="f[]" value="sun" /> Sunday </label>
<br />
<label><input type="checkbox" name="f[]" value="mon" /> Monday </label>
<br />
<label><input type="checkbox" name="f[]" value="tues" /> Tuesday </label>
<br />
<label><input type="checkbox" name="f[]" value="thurs" /> Wednesday </label>
<br />
<label><input type="checkbox" name="f[]" value="thus" /> Thursday </label>
<br />
<label><input type="checkbox" name="f[]" value="fri" /> Friday </label>
<br />
<input type="submit" value="SUBMIT"/>
</form>
My PHP code is:
<?php
$period=$_POST['period'];
$arr2=$_POST['f'];
?>
<table border='2'>
<?php
$count=count($arr2)-1;
for($i=0;$i<=$count;$i++){
echo "<tr><td>";
if($i==0){
echo "<table>";
echo "<div class='wrap_p'>";
for($r=1;$r<=$period;$r++){
echo "<td>";
echo "<div class='add_css'>";
echo $r;
echo "</div></td>";
}
echo "</div>";
echo "</table>";
}
echo "</tr><tr><td>";
echo $arr2[$i];
echo "</td>";
echo "<td> <input type='text' size='20' /></tr></td>";
}
?>
</table>
source
share