UPDATE DATABASE USING THE MULTIPLE OF CHECKBOX VALUES
Posted: Sun Jan 16, 2011 1:36 am
I am knew to php.How to update the mysql database using the multiple checkbox values.
***** PLEASE USE PHP CODE TAGS *****
***** PLEASE USE PHP CODE TAGS *****
Code: Select all
<?php
$result = mysql_query("SELECT * FROM att");
if(mysql_num_rows($result)>0)
{
$i=0;
while($row = mysql_fetch_array($result))
{
$del=0;
$regno=$row['regno'];
$fname=$row['fname'];
$i++;
?>
<tr>
<td width="18%" height="42" align="center"><?php echo $i;?></td>
<td width="26%" align="center"><?php echo $regno;?></td>
<td width="28%" align="center"><?php echo $fname;?></td>
<td width="28%" height="42" align="center"><input type="checkbox" name="<?php echo $regno;?>" value="0"/></td>
</tr>
<?php
}
}
?>
<tr>
<td height="42" colspan="4" align="center"><input type="submit" name="submit" value="SUBMIT"/></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>
<?php
if(isset($_POST['$regno']))
{
$result = mysql_query("SELECT * FROM att");
if(mysql_num_rows($result)>0)
{
$regno=$_REQUEST['regno'];
$fname=$_REQUEST['fname'];
echo $regno;
$i=1;
while($row = mysql_fetch_array($result))
{
if($regno==$row['regno'])
{
$result1=mysql_query("insert into att (fh) values (0)");
$result1=mysql_query("commit");
}
}
}
}
?>