I'm trying to get a button to work , I'm not allowed to use Javascript and here's my code:
<form id="form1" name="form1" method="post" action="course_man.php">
for($i=0; $i <= $numcourses; $i++){
echo '<div class="new'.$i.'" id="new'.$i.'"><label>'.$course_names[$i].'</label>
<input name="edit'.$i.'" type="submit" value="Edit" />
<input name="delete'.$i.'" type="submit" value="Delete" /><br /></div>';
$name= "'edit".$i."'";
if (isset($_POST[$name])){
echo '<input name="text" type="text" value="'.$course_names[$i].'" />';
}
}
?></form>
Now the buttons gets created and no errors are displayed, but the edit button doesnt create the textfield when clicked, what am I doing wrong?
$name= "edit".$i;
if (isset($_POST[$name])){
not: $name= "'edit".$i."'";
<form id="form1" name="form1" method="post" action="">
<?php
$course_names = array('maths','english','science','history');
$numcourses = count($course_names);
for($i=0; $i < $numcourses; $i++){
echo '<div class="new'.$i.'" id="new'.$i.'">';
echo '<label>'.$course_names[$i].'</label>';
echo '<input name="edit'.$i.'" type="submit" value="Edit" />';
echo '<input name="delete'.$i.'" type="submit" value="Delete" /><br />';
echo '</div>';
$name = 'edit'.$i;
if (isset($_POST[$name])){
echo '<input name="text" type="text" value="'.$course_names[$i].'" />';
}
}
?>
</form>
Hope this helps, Ive tested and seems to work fine )