Luke
04-06-2015, 01:39 PM
I'm absolutely stumped by this so I'll try and explain it the best I can.
I'd like to make an attendance system for a web app I'm making (nothing public, just a closed personal system). I want to grab all the data from the 'users' table and display the 'forename' and 'surname' on a table. Then each 'name' will have a radio button group. Like this:
<?php
include "functions.php";
$query = "SELECT * FROM users ORDER by surname ASC";
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_assoc($result);
?>
<table>
<tr>
<td>Name</td>
<td colspan="5"></td>
</tr>
<form id="form" name="form" method="post" action="process.php">
<?php do { ?>
<tr>
<td><?php echo $row['forename']. ' ' .$row['surname']; ?></td>
<td><input type="radio" name="<?php echo $row['id']; ?>" id="<?php echo $row['id']; ?>_PU" value="PU" >PU</td>
<td><input type="radio" name="<?php echo $row['id']; ?>" id="<?php echo $row['id']; ?>_PC" value="PC">PC</td>
<td><input type="radio" name="<?php echo $row['id']; ?>" id="<?php echo $row['id']; ?>_AA" value="AA">AA</td>
<td><input type="radio" name="<?php echo $row['id']; ?>" id="<?php echo $row['id']; ?>_S" value="S">S</td>
<td><input type="radio" name="<?php echo $row['id']; ?>" id="<?php echo $row['id']; ?>_AWOL" value="AWOL">AWOL</td>
</tr>
<?php } while ($row = mysql_fetch_assoc($result)); ?>
</form>
</table>
Now, what would I have to do, so that when I press the submit button, it will get all this data, and add the data to a table called attendance? I want the table to look something like this
id
user_id
record
date
*AI*
1 (or row['id'])
PU (or one of the radio buttons)
CURRENT_TIMESTAMP
with the id and date being automatic.
Can anyone shed any light? I'm pretty new to this and just tinkering around
Many thanks in advance
I'd like to make an attendance system for a web app I'm making (nothing public, just a closed personal system). I want to grab all the data from the 'users' table and display the 'forename' and 'surname' on a table. Then each 'name' will have a radio button group. Like this:
<?php
include "functions.php";
$query = "SELECT * FROM users ORDER by surname ASC";
$result = mysql_query($query) or die(mysql_error());
$row = mysql_fetch_assoc($result);
?>
<table>
<tr>
<td>Name</td>
<td colspan="5"></td>
</tr>
<form id="form" name="form" method="post" action="process.php">
<?php do { ?>
<tr>
<td><?php echo $row['forename']. ' ' .$row['surname']; ?></td>
<td><input type="radio" name="<?php echo $row['id']; ?>" id="<?php echo $row['id']; ?>_PU" value="PU" >PU</td>
<td><input type="radio" name="<?php echo $row['id']; ?>" id="<?php echo $row['id']; ?>_PC" value="PC">PC</td>
<td><input type="radio" name="<?php echo $row['id']; ?>" id="<?php echo $row['id']; ?>_AA" value="AA">AA</td>
<td><input type="radio" name="<?php echo $row['id']; ?>" id="<?php echo $row['id']; ?>_S" value="S">S</td>
<td><input type="radio" name="<?php echo $row['id']; ?>" id="<?php echo $row['id']; ?>_AWOL" value="AWOL">AWOL</td>
</tr>
<?php } while ($row = mysql_fetch_assoc($result)); ?>
</form>
</table>
Now, what would I have to do, so that when I press the submit button, it will get all this data, and add the data to a table called attendance? I want the table to look something like this
id
user_id
record
date
*AI*
1 (or row['id'])
PU (or one of the radio buttons)
CURRENT_TIMESTAMP
with the id and date being automatic.
Can anyone shed any light? I'm pretty new to this and just tinkering around
Many thanks in advance