Question: $qcount=1; while($row=mysql_fetch_assoc($fetch1)) { ?> <tr> <td><?php
ID: 3551794 • Letter: Q
Question
Question:
$qcount=1;
while($row=mysql_fetch_assoc($fetch1))
{
?>
<tr>
<td><?php echo $row['sub_title']."<br>";?></td>
<td><input type="radio" name="<?php echo $qcount;?>" value="1"/></td>
<td><input type="radio" name="<?php echo $qcount;?>" value="2"/></td>
<td><input type="radio" name="<?php echo $qcount;?>" value="3"/></td>
<td><input type="radio" name="<?php echo $qcount;?>" value="4"/></td>
<td><input type="radio" name="<?php echo $qcount;?>" value="5"/></td>
</tr>
<?php
$qcount+=1;
}
if(isset($_post['btnsubmit']))
{
for($i=0; $i<$qcount; $i++)
{
$result[i]=$_post[$qcount]; //error
$i+=1;
echo $result[i];
}
}
?>
how to get post to $result ??
Explanation / Answer
/* instead of using "$_post" you have to use '$_POST' all in capital letters. */
$qcount=1;
while($row=mysql_fetch_assoc($fetch1))
{
?>
<tr>
<td><?php echo $row['sub_title']."<br>";?></td>
<td><input type="radio" name="<?php echo $qcount;?>" value="1"/></td>
<td><input type="radio" name="<?php echo $qcount;?>" value="2"/></td>
<td><input type="radio" name="<?php echo $qcount;?>" value="3"/></td>
<td><input type="radio" name="<?php echo $qcount;?>" value="4"/></td>
<td><input type="radio" name="<?php echo $qcount;?>" value="5"/></td>
</tr>
<?php
$qcount+=1;
}
if(isset($_POST['btnsubmit']))
{
for($i=0; $i<$qcount; $i++)
{
$result[i]=$_POST[$i]; //qcount changed to $i
$i+=1;
echo $result[i];
}
}
?>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.