I am trying to populate two dropdown menus with items in a lookup table. So far I have this:
<label for="search_for_<?php echo $field['name']; ?>"><?php echo $field['label']; ?></label>
<select name="search" class="select">
<option value="<?php echo $field['name']; ?>"><?php echo $field['label']; ?></option>
</select>
which gives me the drop down menus but only populates them with the names of the columns and not the data in the rows.
Searched high and low for this but most suggestions remove even the 'header' and leave the drop downs blank.
Related
Im having issues with data not being entered into the db. I have a form with 5 inputs and a select The drop down select is a dynamic list fro the db. When the form is submitted nothing is entered in the db for the campaign_owner columns. I have the values="" which I think is the problem, but I also tried
<option value="<?php echo $user['username']; ?>"><?php echo $user['username']; ?></option>
yet that doesn't help.The dropdown shows the data I want and allows you to select it on the page it just doesn't submit it and I dont know why.
HTML:
<div class="col-sm-5 col-sm-push-1 form-group required">
<label class="control-label" ><?php echo $entry_owner; ?></label>
<select name="user-list" id="user-list">
<?php foreach ($users as $user) { ?>
<option value="<?php echo $user['username']; ?>"><?php echo $user['username']; ?></option>
<?php } ?>
</select>
</div>
HTML forms work with the input/select/textarea etc. names. Your select is named "user-list" which means that when submitted it will be under the key user-list. You'll need to map that to the campaign_owner column.
I am trying to get a dropdown list to populate. I have two tables, a registration table and a studentclasses table. I am looking to populate the dropdown list from the class table, as a field entry in the registration table. My code is as follows:
<p>Class: <select name="classID">
<?php $classlist_sql="SELECT * FROM studentclasses";
$classlist_qry=mysqli_query($dbconnect, $classlist_sql);
$classlist_rs=mysqli_fetch_assoc($classlist_qry);
do { ?>
<option value="<?php echo $classlist_rs['classID']; ?>"
<?php
if($classlist_rs['classID']==$_SESSION['signuptest']['classID']) {
echo "selected=selected";
}
?>
><?php echo $classlist_rs['classcode']; ?></option>
<?php } while ($classlist_rs=mysqli_fetch_assoc($classlist_qry));
?></select>
</p>
My Studentclasses table has the fields classID and classcode, and I am wanting the classcode to appear in the drop down.
Any help would be greatly appreciated.
I need to populate dropdown with data from mysql database, i do that with this code
Maker: <br>
<select name="maker" >
<?php
$sql="select name from makers";
$query=mysql_query($sql);
while($row=mysql_fetch_array($query)){
?>
<option value="<?php echo $row["name"] ?>"><?php echo $row["name"] ?></option>
<?php
}
?>
</select>
<br>
And now i need to change the design and make it little nicer using bootstrap dropdown, but i don't know how to connect this code with bootstrap code for dropdown
To use the bootstrap-styled selects, just add the form-control class to your <select>:
<select name="maker" class="form-control" >
I'm trying to make auto dropdown list with quantity of products.
okay, that's problem (cms - opencart)
I have In default input to write product qnt:
<input type="text" name="quantity" size="2" value="<?php echo $minimum; ?>" />
$minimum is that you set when uploading product.
I want to make dropdown list with options.
Now I'm trying to change to select, and thats my code:
<select name="quantity">
<?php foreach ($discounts as $discount) { ?>
<option name="quantity" value="<?php $discount['quantity']; ?>"><?php echo sprintf($text_discount, $discount['quantity'], $discount['price']); ?></option><br />
<?php } ?>
</select>
okay thats good in preview, I'm get my select list, but then customer select one from the list, It not quanty for product, always all options set to = 1.
In prieview text $discount['quantity'] show correctly number, but not set to value.. Please help :)
Don't set the attribute "name" to the option tag. This might be the issue. And there is also no need for the br tag after each option. It should look like this:
<select name="quantity">
<?php foreach ($discounts as $discount) { ?>
<option value="<?php echo $discount['quantity']; ?>"><?php echo sprintf($text_discount, $discount['quantity'], $discount['price']); ?></option>
<?php } ?>
</select>
You guys have been patient with me and very helpful so far, so I'll try another one. I have looked around on here and tried many different options of select="selected" and I just can't get the code right or something, a simple fix I'm sure for you guys. What I'm trying to do is have a drop down list that is populated from a table of countries, default to the United States. Here is the code:
<select name="cnt" id="">
<option value="">Select</option>
<?php
$rescnt=mysql_query("select * from `country` ORDER by cnt_name ASC");
while($rowcnt=mysql_fetch_array($rescnt)) {
?>
<option value="<?php echo $rowcnt['cnt_id']; ?>"><?php echo $rowcnt['cnt_name']; ?></option>
<?php } ?>
</select>
Assuming the cnt_id for the United States is 'US', the option line should be:
<option value='<?php echo $rowcnt['cnt_id']; ?>'<?php if($rowcnt['cnt_id']=='US') echo ' selected'; ?>><?php echo...