How to pass values from array into mysql with php
Posted
by
moustafa
on Stack Overflow
See other posts from Stack Overflow
or by moustafa
Published on 2011-01-02T17:48:45Z
Indexed on
2011/01/02
17:53 UTC
Read the original article
Hit count: 141
php
my original code is this
<tr>
<th>
<label for="user_level">
User Level: * <?php echo isset($valid_user_level) ? $valid_user_level : NULL; ?>
</label>
</th>
</tr>
<td>
<select name="user_level" id="user_level" class="sel">
<option value="">Select one…</option>
<option value="1">User</option>
<option value="5">Admin</option>
</select>
</td>
this give me the option to select one of choice from the drop down menu i.e. user and when user is selected and the submit button is pressed this will insert the value 1 into the database which will when the user logs in tell the system that they are are normal user. I want to change the code to the following
<tr>
<td>
<select name="user_level" id="user_level" class="sel">
<option value="">Select one…</option>
<?php
if(!empty($level)) {
foreach($level as $value) {
echo "<option value='{$value}'";
echo getSticky(2,'user_level',$value);
echo ">{$value}</option>";
}
}
?>
</select>
</td>
</tr>
With this being my array query $level = array('User','Admin');
How can I pass the values of 1 for user level and 5 for admin in this code so when the user is selected it inouts 1 into the database?
© Stack Overflow or respective owner