I would like a new item to be added to an array if a button is pressed
This is my code...
$engineers = array();
if(isset($_POST['add_user'])){
$engineers[] = $_POST['engineer'];
$array_count = count($engineers);
}
All it does is replace the only item in the array rather than add to it, where am I going wrong?
Thanks
The form used is
$dropdown = '<select id="engineer" name="engineer" class="select_engineer" type="text" name="engineer" /><option>Select Diary</option>';
while($row = mysql_fetch_assoc($result)){
$dropdown .= "\r\n<option value='{$row['user_name']}'>{$row['user_name']}</option>";
}
$dropdown .= "\r\n</select>";
">
(The list of engineers is populated from a MySQL database).
There isn't anywhere else that adds to the array, I just want a button that will add the engineers user name to the array
$_POST['engineer']to the array - where else are you adding things to$engineers?