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
your array resets every time you reload the page.
you have to store the data in cookies or sessions or database or …
simple idea :