Populating A Drop Box With Results From Database
I have a MySQL database with a table (category) with two fields, catId (int) and category (char(50)). What I want to do is to get all category names in this database and place all of them into a dropdown box on a web page so that the user can choose from the list of available categories.
View Complete Forum Thread with Replies
Related Forum Messages:
Populating Form From Database, Then Passing Results To Next Page
I have a multiple select input in a form that's being populated by a row from my database as such: <input type="checkbox" name="subm[]" value="$row[ID]"> That part is working fine as I can check the displayed page using View Source and see that the value is the correct row number from the database. It is then being submitted on a form by $_POST method to another page where I want to evaluate the checkboxes and display the contents of the entire row that corresponds to each value="$row[ID]" that have been checked. But I can't seem to get it to work. I'm having a problem passing the selected value. Can someone point me in the right direction? $query = ("SELECT * FROM `table`"); $result = mysql_query($query); print "<p>Data for Selections:"; print "<table border=2><tr><th>You chose:"; foreach ($_POST['subm'] as $value) { print "<tr><td>"; print "$row[ID]; "; print mysql_field_name($result, 1) . ": " . $row[name]."<br>"; print mysql_field_name($result, 2) . ": " . $row[address]."<br>"; print mysql_field_name($result, 3) . ": " . $row[city]."<br>"; print "</td></tr>"; print "</table> "; } if (!isset($_POST['subm'])){ print "<p>No matching entry "; } mysql_close();
View Replies !
Retrive A Set Of Results From The Database And Disply Them In A Drop Down Menu.
I am having serious trouble trying to get this script to run. I am bascially trying to retrive a set of results from the database and disply them in a drop down menu. The result returned is simply the name of an article, and I want to populate a drop down menu with a list of all the article names in the database. The problem seems to be with the foreach loop as if I take it away the page loads fine at least and the same if I change the loop to a for loop. Code:
View Replies !
Populating Drop Down
How do I do this drop down box ? Making an edit page. I have 2 tables groups id || categoryname program id || cateogry_id I need to populate the groups in it at same time show the selected choice from program. Not showing id but needs to show categoryname with of course the values being the id of groups.
View Replies !
Populating A Drop Down Menu
How would I go about populating a Drop Down menu from data in MySQL? If you can show me wither a URL to learn this, or if you feel like telling me here, that would be great.
View Replies !
Populating Drop Down And Table
I have a database with the following fields. Name | Company | Date values in each column could be repeated, or not. as in there could be several same names with the same company with different dates, or different names with same company. How do I populate a table with this info and have drop down boxes, so that I can narrow down the search? For example: Name | Company | Date 12 | 1 | 1929 13 | 1 | 1929 14 | 1 | 1929 12 | 2 | 1929 12 | 4 | 1929 13 | 1 | 1941 12 | 6 | 1929 So if in the drop down I select '12' under name, only those entries with 12 are shown, and then I can further sort it by selecting only '1' under Company. Hope I'm clear, I manage to complicate things when I post them.
View Replies !
Auto Populating A Drop Down Box
Basically I'm setting up a website which needs an populated drop down box made up from all fields in a specific column of a table in a mysql db.... Here's the code I've made up using various tutorials.... <?php $user = ""; $host = "" $password = "" $dbName = "" /* make connection to database */ mysql_connect($host, $user, $password) OR DIE( "Unable to connect to database"); mysql_select_db($dbName); //did you forget this line? $sql = "SELECT model FROM usedVehicles"; $query = mysql_query($sql) or die(mysql_error() . "<br>$sql"); //use the or die(...) part ONLY IN DEVELOPMENT ?> <form action="action" method="post"> <select name="option"> <?php while ($row = mysql_fetch_array($result)) { echo "<option value="" . $row['model'] . "">" . $row['model'] . "</option> "; } ?> </select> <input type="submit"> </form> I've left out the connection details for obvious reasons... When I upload and try to test this, jus a blank drop down appears... there are definately fields in the column as I have tried the query on phpMyAdmin.
View Replies !
Populating A Drop Down List With Php
I am trying to get a drop down list to populate vbia php. What I have a is a script that allows a airline/user to enter airfare and price for tickets. It dumps them into a database and then allows the user to view/delete/add. I want the user to be able to edit the airfare. I have a drop down list that is set as a variable $ticket_from, $ticket_to. The list contains around 400 cities. When the user clicks 'edit' I have the price population but no the drop down list. How do you go about something like that? I have this right now: Code:
View Replies !
Populating Drop Down Lists
Could anyone help me on populating database driven drop down menus. I am trying to populate a second drop down list based on the selection of the first drop down list. I have the first drop down list running. Not sure about getting the second now.
View Replies !
Populating Drop Down From A Query
I'm trying to populate a drop-down box from the results of a query. I end up with the first option coming through and then blanks in the rest. Something like this... <option value=Acevedo>Acevedo</option> <option value=></option> <option value=></option> <option value=></option> <option value=></option> .......
View Replies !
Self Populating Drop Down Menus
i am trying to do is the following: I have a MySQL database that (very simplified) has a schema like this 'Students(Name, id, Course)' I would like to have a form on a web site that has 2 linked drop down menus, one 'Please select id' and one 'Please select course'. When a user of the site selects there Id from the first drop down menu, i want the second drop down menu to populate itself with the courses held in the database for the given users Id. I would like the first drop down menu to be populated from the database with a query similar to 'SELECT id FROM students'.
View Replies !
Populating Drop Down From MySQL
I am trying to populate a drop down menu of MySQL data using PHP and I have hit a snag. I think its probably something simple that a freah pair of eyes could pick out right away that I am just not seeing... For some reason only the "firstname" part of the data is populating in the drop down and I can't figure out why. When I try to make changes to the echo lines to correct this, nothing shows up including the "firstname" data. Code:
View Replies !
Populating Drop Down Menu
I use the following code snippet to build a drop down menu with the results of a query. How can I set the initial value of this input based on the result of another query? What I am trying to do is update records in the data base. The field WkEndDate is pulled along with the rest of the record and the drop down menu is built from a table of valid WkEndDate values. Code:
View Replies !
Populating Drop Down Fields
I am trying to populate a drop down menu with a mysql database. I was hoping to have a selection of months in the dropdown menu, based on date fields in my database when a user then selects a month, they will be brought to a new page that will have only the records created in that month. But in my database, the date is stored in this format: 2006-05-12 00:00:00 if you need to see my code, here it is: <? //database connection $query = mysql_query("SELECT * FROM casinocredit"); // start to print out the form echo "<form action="cats.php" method="POST"><select name="clients"><option value="" "selected">Select A Client</option>"; // loop through the records while ($row = mysql_fetch_array($query)) { echo "<option value="{$row['ID']}">{$row['ddate']}</option>"; }.........
View Replies !
Populating A Drop Down Via A File Directory?
I just wrote this code: $dir = "/images/news"; print "<select name='file'>"; $dir = opendir($dir); while (false !== ($file = readdir($dir))){ if (in_array($file, array(".", ".."))) continue; print "<option value='$file'>$file</option>"; } print "</select>"; But for some reason it is not populating. It instead echoes an empty drop down menu. Can anyone suggest anything?
View Replies !
Populating A Drop Down From A MySQL Table
When they click submit, I want the name dropped from "invite" and added to a table "guests" with their answer if they are coming and how many. I know the SQL to make it happen, but I am pretty sketchy about the PHP. Code:
View Replies !
Auto Populating Multiple Drop Downs.
im trying to create two dropdowns, i need the first one to be the category and the second one to be the subcategory. The category drop down autopopulates with the correct info from the database. and uses the table "category", the value of each drop down is represented by the "cat" field in the table (cat is basically and integer id number) and "Category" is used as what the user actually sees in the drop down (category is the actual word of the category). Once the category is selected i would like to have the sub category auto populate with everything that has the same values as the selected category (cat) Here is a break down of how the tables work. Table 1 Name: "category" Fields for Table 1: "cat" (the id number), "category" ( the actual name of the category) Table 2 Name: "subcategory" Fields for Table 2: "cat" (corresponds with the cat id from table 1 to pull the correct data), "subc" (the basic id of the subcategory), "subcat" the actual name of the subcategory. so the way i see it, have a normal drop down populated by a php query. then on change, populate subcategory drop down where cat = cat and display sub category.
View Replies !
Populating The Drop Down And Pressing The Submit Button
1. The first is I have two drop down menus. The first is "year" and the second is "mfr". When a user selects a year from the drop down it then populates the second drop down, mfr, from the MySQL database. Theat is working fine. But the problem I am having is the "submit" button (which I have labeled as "browse"). When I click it. Nothing happens, no action tacks place. I have looked over the code and I can't figure it out. (See Code Box 1 Below). 2. Right now the "mfr" drop down is populated by the MySQL database and reads with a list like "Acr", "Alp", etc. These are abreviations. I need to set up an array to have them instead read the entire mfr name. Example: Instead of "Acr" it needs to be "Acura". Instead of "Alp" it needs to be "Alpine". I need these full names to appear in the drop down. I know I need to do something like this (See Code Box 2 Below) but I can't get my finger on it. Code:
View Replies !
Populating Drop Down List With Selected Vaue
I have a drop down box and the "selected" value needs to be selected by a dynamic value that gets entered into the database, this is currently how im doing it: PHP Code: <?php                 if($modify_row[21] == "0") {                   print "<option value=" "></option>";                   print "<option value="1">Active</option>";                   print "<option value="0" selected>In-Active</option>";                 } elseif ($modify_row[21] == "1") {                   print "<option value=" "></option>";                   print "<option value="1" selected>Active</option>"; Its fairly straight forward, basically the option that is automatically selected needs to be the one coming from the database $modify_row[21].
View Replies !
Populating City,state,country Drop Down Menu
In the registration form I have city, state, country fields. I was wondering if there was a database available on the net which has the list of states in each of the countries. That way when a user selects a country I could automatically populate the state drop down menu ...
View Replies !
Drop Down Menu Select And Populating Data Fields
I have a PHP/MySQL Content Management System set up for the job I work at. It's basically a shift program that lets users pick up shifts, post shifts, etc. The data fields are tied to the shift ID which is selected from a dynamically populated drop down box. However, I cannot get the data fields to be updated when I select a new value and I cannot get the form to accept the new selected Shift ID. I have tried using JavaScript but cannot quite get it to work. Code:
View Replies !
Populating Multiple Drop Down Boxes From Mysql Table
Am having a problem with a dynamic, multiple drop down box query. If I run the code with only one select, it populates fine. If I run it with 2 selects then only the first drop down box populates - the second drop down box is empty. Am wondering if I need to put the query into an array and populate the boxes from there. Code:
View Replies !
Populating Array With Mysql Results
I'm returning a result set of one field in a table, and want to populate an array with the results. I can't for the life of me figure out a simple way to do this without using mysql_fetch_array() to cycle through the results, append that to a var, then explode that into a var and pass that. PHP Code:
View Replies !
Populating A Select Box From A Database
I have a subscription database that allows you to edit a subscribers data. For example, you enter a search term like "Bob" and it returns a list of everyone named Bob. You click the one you want and it goes to a subscriber detail page, where all of his data is populated to a form. You can directly edit this form and click save to overwrite it. The only issue is the select boxes (drop downs) - say I have four options in the drop down box, red, blue, green and black. On my details page for bob I end up with five, I have those four PLUS whatever was saved for his color, so it shows up twice. If Bob is green, my select box looks like: Green Red Blue Green Black How can I make it so that Green only shows up once?
View Replies !
Populating A Dropdown From A Database
I have put together a script that populates a dropdown menu from a database. My database contains a table called casinocredit, and it contains records that have been enterend over 2 different months (may and june). There is a field in the database that contains the date in this format: 2006-05-12 00:00:00 So The drop down is currently showing a month for each of those records. I was hoping that it would only display one. (the plan is when a user selects a month (say May) and hits submit, then I would display all of Mays records on a different page) See the image i have attached for a view of what is happening. Code:
View Replies !
Populating A Form Wth Database Info
I've coded a piece of code which populates a form with data read from the database: $connection=mysql_connec ("localhost", "f2821842", "f2821842"); $result=mysql_select_db("QUERIES"); $query=mysql_query("Select * from Emp_Details where emp_num = '$employnum'"); while($row=mysql_fetch_array($query)) {$empname=$row['emp_name'];} <form name="webregform" action="webadmin2.php" method="post"> <input name="requiredname" type="text" size="30" value="<?php echo "$empname"; ?>"> </form> When I echo the $requiredname, I get spaces and no data, and I know that $empname is not a space-it does read a value in a database. 1. How can I get $requiredname to print a value?
View Replies !
Drop Down Results!
I am trying to create a drop down menu of a list of people, and when I click on it I want it to show all the information to that specific person. Here is what I have written so far. Code:
View Replies !
Drop-down From Query Results
I've got a form that pulls data from a MySQL database and populates the form and allows the user to edit the info and submit the changes to the database. All works fine when I'm working with straight text boxes (which comprises the majority of the form). The problem arises when I'm dealing drop-down select boxes. Essentially, what I want to do is to populate the drop-down with all choices but have the one "selected" that was previously in the database. The MySQL tables look like this: leave_type TABLE which has leave_type_id and leave_type_name absence_actions TABLE which has absence_id, personnel_id, leave_type_id, etc... So, I'm looking at grabbing all of the results of the leave_type table to populate the dropdown and then grabbing a specific row from the absence_actions table and making the dropdown "selected" based on the leave_type_id from both tables. Does anyone have any idea on how to code something like this. This seems like a common problem but I can't find anything on google. Perhaps I don't know how to phrase my query.
View Replies !
Display Results In Drop Down Box
I have a form that list a number of drop down boxes. And each time, I add a new option, I have to update the form again. I'd like to possibly create a table for all of the options, and then just have the form read the table and display them in the drop down box. The goal is to have code that I don't have to change each time, but rather just add/update the database as needed.
View Replies !
Trouble With Display Of Drop Down Results
I can get the first two drop down list to work, now the thing is i can't get it to display the results in table after the selections of the drop down lists.. that is to say after the user select the value from the drop down lists.. it should display results onto the table.. How should i do it anyone know? Code:
View Replies !
MySQL Results Into Drop Down Menu
I have a site populates a drop down menu with options, say... Option 1 Option 2 Option 3 Option 4 If i customer is currently set to Option 3, i'd like this to be at the top of the Drop down menu and therefore the default option. This seems like a pretty simple thing but their doesn't seem to be a quick fix.
View Replies !
Drop Down From Database
I have a database with entries such as Clo, Rel_ID Clo, Rel_ID Clo, Rel_ID brown, 1 blue, 2 green, 1 etc I have dropdown menus on the page which have the values from the database the are around 16 variations I have to call in the database each time with the Rel_ID = '1' or '2' etc. is ther a way where I can call in all the entries from the database then hard code the relevant ID on the page? ....
View Replies !
Drop Database
I know this has to be something simple. I have a form in a project tracker that allows admin to create a DB and add a user to it so we can quickly sell and add people. Beside each Current DB is a remove link that passes the same page the global DB ID and if clicked, should remove the entries from the global db and globalusers table as well as drop the created DB and all its records. Right now what I have is removing the records from the first two tables I mentioned but will not drop the DB. Code: if (!empty($_GET["id"])) { //first we get the DB name $query= "select DB from globaldbs where ID = ".$_GET["id"]; $result= @mysql_query($query); $row= @mysql_fetch_array($result); //now we delete the record from the globalusers table $query= "delete from globalusers where DB = '".$row["DB"]."'"; ...
View Replies !
Drop Down Populated By Database
I currently have a php file that pulls a query from the field "category" from my database. this file is called category.php. I am trying to populate a drop down box in another page (called add_subpage.php) from the results of the category page. the code below is on the add_subpage.php file: (It was my best guess and does not work) <select name="category"> <option value="CAT"<?php include 'category.php' ?>></option</select> Can anyone tell me how to make this drop down populate from the category php file?
View Replies !
Drop Down With Assigned Value From Database
I have a database that has customers in it. When they purchase things from me, each purchase is either "online" or "onsite". So a selection must be made as either "online" or "onsite" when the item is entered into the database. Often, I have to update this value for an item later on from "online" to "onsite" and vice versa. Is there anyway to populate the "Type" field with whatever the value is in the datablse for this particular item purchased, then allow someone to select "online" or "onsite" from the dropdown if it needs to be edited? Code:
View Replies !
Adding From Drop Down To Database
i have a script where if you select one of the drop downs, if you have the cash in your credits it will update the database as you having one of them. HOWEVER every time it goes on it gives the player a steak house without clicking on it. anyone? Code:
View Replies !
Drop Down Menu Without Using A Database?
A lot of people are turning off javascript on their browsers so the script doesn't always work. I would like to know Is their a php script that can do the same thing without using a database? Can I get the links to open in a new window when they are selected?
View Replies !
Database Into A Drop Down List
I'm trying to pull data from my database and display this data in a drop down list. I have 3 drop down menus, when a sourcre is selected in the first menu. only the destinations available from that source should be displayed in the 2nd drop down and then the destinations of the next selection displayed in the 3rd drop down.
View Replies !
2 Drop Down List Where Need Query Database
there is drop down list box linked to the database where it displays the state of a country and once the user clicks on the particular state, there purpose to be radio button displaying the locations available of that state, the location displayed in radio buttons are from the database. currently the source code i'm using is (which uses a submit button to query the database but i does not want the submit button it purpose to work using Code:
View Replies !
Searching Database With A Drop Down With The Vales
I have a database set up with 'Areas' such as Birmingham, london, Bristol etc. We have a search page with a drop down with the vales of Birmingham, london etc wich works fine and picks up the relevant data. What we also want to do is have a label of 'All' so that it will pick all the areas, what shuld the value be?
View Replies !
Drop Down Menu Validation Against Database
I want to do a query which selects the config.maps table.field WHERE ladder_id = $ladder_id. I can do this fine, but the next bit is slightly harder. The maps are stored as an array, separated by commas. I can explode these commas to put the maps in to an array called $maps but how can I then check that a value inputted from the drop down menu matches one of these maps? I cannot do: if ($dropdown = $maps[1] || $dropdown = $maps[2] || $dropdown = $maps[3]) { // Continue }
View Replies !
Horizontal Drop Down Menu From Database?
I've been searching now for months and have just given up. I've also tried to create my own menu using pre-made drop down menu software then using dreamweaver to try and get the values from a database but have had no success. I've made a CMS which allows users to greate sub menu items, and then sub-sub menu items to those submenu items. And now the final thing to do is create the drop down menu on the front end of the site. Is there a particular site or software package that anyone could point me to that is very good and allows you to create the menu's based on data in a database? So it will allow me to select which table contains the main buttons, which table contains the sub menu items, and also the sub-sub menu items.
View Replies !
Database Driven Drop Down Menu
I'm trying to create a database driven drop down menu. I feel I'm on to the right path but my code doesn't seem to work. I've looked around and haven't seen where I'm making the mistake. Any one care to take a look? Code:
View Replies !
Add Some Data From Drop Down Menus Into A Database.
I need to add some data from drop down menus into a database. The form loops on itself to add the data. I'm not sure which part I need to add the dollar too, i.e. the select name or the values in the list, in order to make it work. I've included part of the code below: PHP Code: $form.="Cateory 1*: <select name="cat"> "; Â Â Â Â $form.="<option value="Action">Action</option> <option value="Comedy">Comedy</option>"; Â Â Â Â $form.="<option value="Drama">Drama</option> <option value="Family">Family</option>"; Â Â Â Â $form.="<option value="Horror">Horror</option> <option value="Misc">Misc</option>"; Â Â Â Â $form.="</select>
View Replies !
Scriptaculous Drag Drop And Database Integeration!
I'm working on a drag and drop feature with the scriptaculous javascript library. And I was wondering if someone could help me! :( Here is some test code. Basically, when someone takes something from the left side and puts it in the right side, I just want to run a database query. I have NO IDEA how to do this because of my limited javascript experience. <script src="http://www.mytuneslive.com/_NEW/MORPH/javascripts/prototype.js" type="text/javascript"></script> <script src="http://www.mytuneslive.com/_NEW/MORPH/javascripts/effects.js?1.7.0b1" type="text/javascript"></script> <script src="http://www.mytuneslive.com/_NEW/MORPH/javascripts/scriptaculous.js" type="text/javascript"></script> <link rel="stylesheet" href="http://www.wiki.script.aculo.us/stylesheets/application.css" type="text/css" media="screen" /> <div style="height:200px;"> <div style="float:left;"> <h3>This is the first list</h3> <ul class="sortabledemo" id="firstlist" style="height:150px;width:200px;"> <li class="green" id="firstlist_firstlist1">Item 1 from first list.</li> <li class="green" id="firstlist_firstlist2">Item 2 from first list.</li> <li class="green" id="firstlist_firstlist3">Item 3 from first list.</li> </ul> </div> <div style="float:left;"> <h3>And now the second list</h3> <ul class="sortabledemo" id="secondlist" style="height:150px;width:200px;"> <li class="orange" id="secondlist_secondlist1"> <span class="handle">DRAG HERE</spanItem 1 from second list. </li> <li class="orange" id="secondlist_secondlist2"> <span class="handle">DRAG HERE</spanItem 2 from second list. </li> <li class="orange" id="secondlist_secondlist3"> <span class="handle">DRAG HERE</spanItem 3 from second list. </li> </ul> </div>
View Replies !
|