|
I am fairly new to php coding so please bear with me. I have some code that will allow me to take weekly attendance. In my db all the entries are defaulted to Y. So essentially I want to look at my member list and mark the absent members. Right now everything is echoing except the radio buttons.
<?php
$host="*******"; // Host name
$username="****"; // Mysql username
$password="******"; // Mysql password
$db_name="******"; // Database name
$tbl_name="`*********`"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$sql="SELECT * FROM $tbl_name ORDER BY `Last_Name` ASC";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
if(!$result)die(mysql_error());
?>
<table width="500" border="0" cellspacing="1" cellpadding="0">
<form name="form1" method="post" action="">
<tr>
<td>
<table width="500" border="0" cellspacing="1" cellpadding="0">
<tr>
<td align="center"><strong>ID</strong></td>
<td align="center"><strong>First Name</strong></td>
<td align="center"><strong>Last Name</strong></td>
<td align="center"><strong>Sept_08_2008</strong></td>
</tr>
<?php
while($rows=mysql_fetch_array($result)){
?>
<tr>
<td align="center"><? $ID[]=$rows['ID_Number']; ?><? echo $rows['ID_Number']; ?></td>
<td align="center"><? $First_Name[]=$rows['First_Name']; ?><? echo $rows['First_Name']; ?></td>
<td align="center"><? $Last_Name[]=$rows['Last_Name']; ?><? echo $rows['Last_Name']; ?></td>
<td align="center"><? $Sept_08_2008[]=$rows['Sept_08_2008']; ?><?
echo("Yes: <input type='radio' name='Sept_08_2008' value='Y'");
if($Sept_08_2008 == 'Y') {
echo(" checked>");
} else {
echo(">");
}
echo("No: <input type='radio' name='Sept_08_2008' value='N'");
if($Sept_08_2008 == 'N') {
echo(" checked>");
} else {
echo(">");
}
?> </td>
</tr>
<?php
}
?>
<tr>
<td colspan="4" align="center"><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</td>
</tr>
</form>
</table>
<?php
// Check if button name "Submit" is active, do this
if($Submit){
for($i=0;$i<$count;$i++){
$sql1="UPDATE $tbl_name SET name='$First_Name[$i]', Last_Name='$Last_Name[$i]', Sept_08_2008='$Sept_08_2008[$i]' WHERE ID_Number='$ID_Number[$i]'";
$result1=mysql_query($sql1);
}
}
if($result1){
header("location:attendance.php");
}
mysql_close();
?>
|