Hi there,
I have been trying to resolve this problem for hours upon end now...hope someone can help me. Here is my PHP code....
<?php
session_start();
header("Cache-control: private"); //IE 6 Fix
//unregister existing start and end dates (if any exist)
session_unregister("startdate");
session_unregister("enddate");
//connect to the database
$hostname = "localhost"; //or ip address of server
$databasename = "hr";
$username = "root";
$dbpassword = "";
$db = mysql_connect('localhost','root','') or die("could not connect");
mysql_select_db('hr');
//check to see if the user is registered
$query = "SELECT emp_forename,emp_surname,hol_req_id,hol_start_day_name,hol_start_day,hol_start_month,hol_start_year,
hol_end_day_name,hol_end_day,hol_end_month,hol_end_year,hol_total_days,hol_req_approved
FROM hol_request,emp WHERE hol_request.emp_id = emp.emp_id AND dept_id = '$Dept'
AND hol_req_approved='P'";
$result = mysql_query($query);
//$Taken_Hol=0;
echo "Leave requiring approval/rejection:<br><br>";
echo '<table border="1" cellpadding="0" cellspacing="0" bgcolor="#C5D8EB">';
echo "<tr>";
echo "<td>";
echo "<b>Employee Name</b>";
echo "</td>";
echo "<td>";
echo "<b>Start Date</b>";
echo "</td>";
echo "<td>";
echo "<b>End Date</b>";
echo "</td>";
echo "<td>";
echo "<b>Total Days</b>";
echo "</td>";
echo "<td>";
echo "<b>Approve</b>";
echo "</td>";
echo "<td>";
echo "<b>Reject</b>";
echo "</td>";
echo "</tr>";
echo '<form name="poocrap" method="post" action="confirmapprovereject.php">';
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
echo "<tr>";
echo "<td>";
echo $row['emp_forename'];
echo " ";
echo $row['emp_surname'];
echo "</td>";
echo "<td>";
echo $row['hol_start_day_name'];
echo " ";
echo $row['hol_start_day'];
echo " ";
echo $row['hol_start_month'];
echo " ";
echo $row['hol_start_year'];
echo "</td>";
echo "<td>";
echo $row['hol_end_day_name'];
echo " ";
echo $row['hol_end_day'];
echo " ";
echo $row['hol_end_month'];
echo " ";
echo $row['hol_end_year'];
echo "</td>";
echo '<td align="center">';
echo $row['hol_total_days'];
echo "</td>";
echo '<td align="center">';
$val = $row['hol_req_id'];
echo $val;
echo '<input type="radio" name="loc" value="$val"></input>';
echo "</td>";
echo "</tr>";
}
echo "</table>";
echo '<span class="style1">(P = Pending, A = Approved, R = Rejected)</span><br><br>';
echo '<input type="submit" name="Submit" value="EnterSubmit">';
echo "</form>";
?>
Now, what I am trying to do is populate the values of the radio buttons on every iteration of the while loop with whatever $val is, and then pass this value onto confirmapprovereject.php when the submit button is pressed. Even better, I wanted it so that when the user clicks on a radio button the value gets passed straight to confirmapprovereject.php rather than having to click on the Submit button, but thats not essential.
I think the problem is with the following line of code:
echo '<input type="radio" name="loc" value="$val"></input>';
PLEASE SOMEONE HELP ME!! IT'S DRIVING MR CRAZY, AND AS USUAL, IS PROBABLY SOMETHING VERY SIMPLE!!
Thanks,
Andy Thomas