Forum Moderators: coopster
$view_current_employees_sql = "SELECT * FROM com_employee WHERE date_left_employment IS NULL order by first_name";$view_current_employees_return = mysql_query($view_current_employees_sql);
while($row=mysql_fetch_array($view_current_employees_return))
{
$employee_id = $row[0];
$first_name = $row[1];
$last_name = $row[2];
$pay_scale = $row[3];
$percentage = $row[4];
$date_of_hire = $row[5];
?>
<tr>
<td><input type="checkbox" name="employee[]" value="<?php $employee_id ?>">
</td>
<td><?php echo $first_name?>
</td>
<td><?php echo $last_name?></td>
<td><?php echo $pay_scale?></td>
<td><?php if($percentage == NULL)
echo "n/a";
else
echo $percentage;
?>
</td>
<td><?php if($date_of_hire == NULL)
echo "unknown";
else
echo "$date_of_hire";
?>
</td>
</tr>
if(isset($_POST['employee']))
{
echo "it's set<br/>"; /// WORKS
$employee = $_POST['employee'];
echo "$employee[0]"; ///DOESN'T WORK! :(
}
$view_current_employees_sql = "SELECT * FROM com_employee WHERE date_left_employment IS NULL order by first_name LIMIT 1";
$view_current_employees_return = mysql_query($view_current_employees_sql);
while($row=mysql_fetch_array($view_current_employees_return))
{
print_r($row);
}
See if what that looks like and if your getting what you want / expect from your db query.
William.
echo '<pre>'.htmlentities(var_export($employee, true)).'</pre>'; or what i usually do when debugging:
echo '<pre>'.htmlentities(var_export($_REQUEST, true)).'</pre>'; That'll give you a clue about what's exactly being passed into your script. But anyways, i suspect the problem is here:
... value="<?php $employee_id ?>" I think it should be:
... value="<?php [b]echo[/b] $employee_id[b];[/b] ?>" Take a look at the generated page's source to see if your <checkbox> is formed properly.
array(2) { [0]=> string(0) "" [1]=> string(0) "" }
The empty strings tell you there's no value in the checkbox. So when you print "$employee[0]" it actually IS printing $employee[0]. It's just a blank string.
<input type="checkbox" name="employee[]" value="<?php $employee_id ?> <--- Note missing closing " quote
I don't **think** it's from the missing last quote - it might be - but more importantly, make sure you're actually getting a value from $employee_id.