Dropdown Lists
I've been doing a site for a while now that has several drop down lists in a form. On one form there is the same drop down list repeated 3 times from the same table in a database but with different values. What would be the best way to repeat the code without repeating all of the code. Basically looking at an more economical way to do things. Would you do a while statement and loop through them or maybe a single array and call it when you need it. Any opions?
View Complete Forum Thread with Replies
Related Forum Messages:
Dynamic Dropdown Lists
I am recoding a greeting card website. I am using dropdowns as filters for items in a DB, so when the user picks "animals" from the "theme" dropdown, the returned cards all feature animals, and when the user picks "birthday" from the "message" option, the returned cards all feature birthday cards. However, there are some combinations that don't return any results, for example "get well" "floral" cards. Code:
View Replies !
Classes And Dropdown Lists
The class below works fine. The problem I have is there's a dropdown list in the middle of the loop. The dropdown list gets its data from another table in the database. Which goes through the same class. So I have a loop within a loop. What I'm trying to do is ....
View Replies !
Create State-cty Dropdown Lists
I've gotten everything up and running except for this -- I'd like to be able to have people have a dropdown list of cities in the US to use (or wherever) and not have to input them manually into a text field. When you do then there are issues of misspellings, etc. Now I have a list of cities from each state that is a sample that works in an html page. Problem is that it takes up 2 MB! Way too much to load on a single page and I was wondering how this is accomplished best -- do people use javascripts that can pull information from another flat flie? Do people use PHP to connect to a mysql database that might have a list of these fields and then reloads the page? I'm really not sure of best options and would be grateful for anyone to give me pointers or whether there are other examples and even places to buy these databases (not likely but good to have if I decide to do so.)
View Replies !
Get Two Dropdown Lists Working On A Page
i am trying to get two dropdown lists working on a page. How do i go about this. For example, I have 1 table which holds countries and cities. When a user selects a country in the first dropdown list, i'd like the second dropdownlist populate with a list of cities etc. from my database.
View Replies !
Auto Select Dropdown Lists From Db Values
I want a simple HTML drop-down list like this: Code: <select name="select_1"> <option name="option_1" value="option_1" selected="true"> <option name="option_2" value="option_2" selected="false"> </select> to be able to automatically select a value according to a value in a table in the database. For example, if a MySQL table has a field named "field_1", and one of the rows has a value of "option_1" in that field, I want the list (using PHP of course) to automatically select the option name "option_1".
View Replies !
Dynamic Dropdown And Hardcode Dropdown In Select Form
I have plenty of examples of dynamic dropdown choices but none of hardcoded dropdown choices. The ultimate goal is to have a job with various tasks and to track the status of those tasks for a given job. I've used one of the tutorials here to begin the process. Below is the code I have to add work on a given task. Perhaps I actually need to "Update" a job as opposed to "add". But the problem of the moment is I can't seem to hardcode one set of my options. This is the code I have: PHP Code:
View Replies !
Mailing Lists
I have searched in many places about how to set up a mailing list that is scalable yet no web sites seems to want to give out this info. I need to have this mailing list be effective even up to hundreds of thousands of users. Any advice/resources on how to set up this mailing list?
View Replies !
Email Lists
How would I go about making email lists? Someone who has something similar to what I want told me that they handle it with PHP. I'm not talking about a form where I can email an entire list, but rather an email GROUP, such that any time email went to URL from ANYONE that is a member of my site, it would come into domainname.com, and then sent back out to everyone in the "group". Any info would be helpful. Is this possible with php? What is the email process? Right now I'm not even on a domain name on my own server.
View Replies !
Ordering Lists
I have developed a script (with help) that tries to order events stored in my .txt file by date. The .txt file looks like this: 1st|Jan|Meeting at House| 15th|Feb|Meeting at your House etc The script orders the dates from lowest to highest but does not order dates before the 10th. Apparently 1st - 9th comes after 31st.. Code:
View Replies !
PHP And Drop-down Lists
I want a simple HTML drop-down list like this: <select name="select_1"> <option name="option_1" value="option_1" selected="true"> <option name="option_2" value="option_2" selected="false"> </select> to be able to automatically select a value according to a value in a table in the database. For example, if a MySQL table has a field named "field_1", and one of the rows has a value of "option_1" in that field, I want the list (using PHP of course) to automatically select the option name "option_1". How would I go about doing that?
View Replies !
Drop Down Lists
I have used Php to generate a drop down but becos the action of the form is it itself ($_SERVER) I need to echo the value upon submission. Becos this is php generated I'm having problems. This is what the current code looks like: [PHP] echo "<select name="branch"> <option value="$variable">$variable</option> </select>";
View Replies !
Maintaining Mailing Lists
I've few doubts; I'm asking two problem here. 1st, can we use PHP for maintaining mailing-lists. Say, we've 1000 users, need be e-mailed a subscription newsletter i.e. $message is same, loop through e-mail array in db. 2nd, Web site search. We maintain database after reading files using PHP and manipulate results from db. Question is, if PHP is a solution for these problems, also, when users' ( 1 ), keywords' ( 2 ) dbs grow big! There is also a limit of a PHP script execution. In 1st case, PHP has to parse, suppose 10k subscribers, and generate 10k e-mail for sendmail program. Is PHP feasible for such things. What else, is a better and professionally used solution. I don't know CGI? Perl?
View Replies !
Multiple Selection Lists?
i have a mutliple selection list on a form that goes like this <select name='name' multiple size=6>"; echo "<option value='one'>one"; echo "<option value='two'>two"; echo "<option value='three'>three"; etc it works fine. BUT how do u call it. For example say i selected option one and three. How do i call that on the next page so that ONE and THREE are stored.
View Replies !
Less-expensive Way To Set Up Defaults In Lists Etc?
I'm currently setting up default selections in <select> lists by passing an array of those defaults as keys ( 'valuefoo' => true ) as an argument to the function that sets up the list. Then, as I build each <option>, I call array_key_exists ( thisoptionvalue, arrayofdefaults ) to check whether to include the 'selected="selected"' string. So the code looks something like Routine ( array( 'valuefoo' => true, 'valuebar' => true ) ) ; ..... function Routine ( $defaultvals ) { for ( $i= etc. ) echo '<option....' . ( array_key_exists( 'curroptval', $defaultvals ) ? 'selected="selected"' : '' ) . etc ' ; } (I've elided a lot of syntax, but you get the idea) That seems slow and tedious. Does anyone know a cheaper way?
View Replies !
Quote's Invoices Lists...
I need someone to bounce some ideas off. This is what I'm trying to do, I want to be able to create a script that will spit out a quote based on the information filled in. The part I'm stuck on is. Entering all the items in. Ok, say I have a form, it starts off where you put in all the details (eg, who the quote is for address phone no etc.) Then there will be a list of items to go onto the quote. Now this is the part I'm stuck on. I'm thinking maybe something like an add new item button that opens a new window and then you enter in the details for each item. This then adds each item to the quote. Each item that is entered can be added directly to the database. So what I'm thinking maybe is a popup window that you fill in the details for each item, you hit submit, and then it goes back to the origional quote page, but now with the item added to the list. Maybe is there java script where you can open a new window and then refresh the parent window when the child is closed? this would then have the items listed.
View Replies !
Multiple Lists Selection
I am using a simple registration form that i made with the toolbox, but when I come to a multiple list to choose from (populated from the database) it doesn't work correctly. Of course, out of the multiple items selected only the last one gets inserted. From what I have read, the selection must be turned into an array then looped for this to work. Is this correct? Next how would I code this to work right. If you let me know which code to post, I will post it.
View Replies !
Multiple Selection Lists &
I have 2 multiple selection lists. I am using javascript so that users can select items from list 1 and move them to list 2. When the user submits the form I need my php to get the values he has/she has in list 2... I have done printf($_POST['list_2']) and it only shows one value, even when multiple are selected. I read that I need to change it's name to list_2[] but if I add the brackets to the name my javascript quits working.
View Replies !
Updating Lists On Page
The problem is that I am displaying all the rows of my table which have the value of the field 'approval' as 0. Now, there are to be 2 buttons next to each row with names "Approve" and "Disapprove". If you click on approve, then the value of 'approval' for that row becomes 1 and if you click on "Disapprove" , the value of 'approval' becomes -1. How to accomplish it ? as the list being viewed will be changing very often. 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 !
Making Lists Of Words
Say I save into a field of a mySql database something like "two, three, four, five, six" all within one field, and then save each individual value into a spot in an array. So my array would go somewhat like a[0]=two a[1]=three and so on. I know how to do this in Java, but not in PHP. Similarly, is it legal so write $string = five; $string = $string + ',' + 'six'
View Replies !
Dynamic Unordered Lists
I have searched about for this one but havent quite found the low down i'm looking for but here goes. I'm trying to dynamically populate an unordered list from an SQL database which will have upto 5 or 6 sub-selections per top level list item so.. it would do something like this: Code:
View Replies !
Dpendent Drop Down Lists
I'm making a system for outage reports, I have a field that refers to the outage type. I want when choosing from the list, for example, POP, all fields hat doesn't refer to POP issues to disappear. I made a demo with a software PHPrunner 4.1 and you can check it out. exapmle: I choose DNS so all feilds refer to POP and other issues should disappear.
View Replies !
Generating Combo Lists
Lets say I have an array: $fruitarr = array("apple", "banana", "orange", "lemon", "lime", "strawberry"); And I need to generate a list of smoothies over a period of 8 weeks. Each week only two of the fruits can be used together at a time. So for example, the choices for week 1 would be: Code:
View Replies !
Drop Down Lists And Textfields
I've found this is a great place to learn, so hopefully such can happen with the following: Basically, I'm trying to develop a world market for a text-based game wherein what is available is listed inside a drop-down list, followed by an input box where the user can enter the amount to purchase (up to the quantity amount available) and submit. Likewise, I've got a drop-down list populated via a MySQL query. Altogether, the page looks like this: My question is, how does one associate the input box with the drop-down list, assuming it's possible (which I would assume)? Currently, it displays correctly, however when one submits via the "Purcase Goods" button, nothing occurs. I'm not quite sure how to integrate everything coherently; my knowledge is limited in the area of PHP/HTML integration, so any explanation would be kindly appreciated. I know long streams of code are often unhelpful in pinpointing a problem (or problems), but in the interest of not excluding an element, here's the code of the file in question: ....
View Replies !
Putting Lists In Order
I have produced a noteboard style calendar where all events of a particular month are called and then number representing the date is shown and then the event after it. I'd like to know if possible the code which will order the numbers from the lowest to highest number. <?php function getevents($eventmonth){  $file = file("data.txt");  foreach($file as $key => $val){   $data[$key] = explode("|", $val);   $day = $data[$key][0];   $month = $data[$key][1]; ........................
View Replies !
Keeping Selection Lists
I would like to create 2 single-select drop-down selection boxes on a page box1 - select academic year from 2001, 2002 , 2003 etc box2 - select semester from 1, 2, 3 etc As a result course details for all courses that satisfy these selection values get displayed below the boxes. The boxes remain availabel on the page. The user should be able to re-set these boxes to different values to generate different results. The boxes remain visible on the page. Is this possible ?
View Replies !
MySQL Lists All The Results
I have this code which works well, it lists all the results. but in results_data i have team1 and team2 feilds. I want to add a code to this so that if either team1 or team are = to say $teamsetid then it will show the row but no others. How can this be done? PHP Code: $result = mysql_query ("select * from results_data where group_id = $latest_group_id and comp_run_id = $compid order by list_order");
View Replies !
Have 3 Lists <selectfunction In A Form.
I have a huge list of selectives in a database. What I want to do is have 3 lists <selectfunction in a form. 1 list will have countrys, another list will have citys. When a country is selected, I want the list of citys to show that is in that country, if there is no citys i want it to go straight to the 3rd list. Is this possible in php? if so do you have any examples.
View Replies !
Allowing Edits Of Lists
I want to provide users a page where they can browse entries in a database 10 at a time, for example. I am doing this as a table, where each row is a database entry. I want to be able to give the user the ability to modify entries. By either clicking on a link or a button on each row, I want the user to be sent to another page to edit that entry.
View Replies !
Showing Lists By State
I need to pull out a large list of companies out of a database for display on the web. They are listed by state, and I can sort them by state, but I need to show the state name as a heading above each state's list.
View Replies !
Mysql Generated Lists
I have a page where I am populating a list from a mysql database table with a variable passed from a previous page. code snippet: PHP Code: // set varibles $company = ($_POST['cds_user_company']); $pass = ($_POST['cds_passtext']); // Query the database $query_plist = "SELECT * FROM cds_projects WHERE cds_company - $company ORDER BY cds_proj_name DESC"; $result_plist = mysql_query ($query_plist) or die ("query_plist on project_list.php failed to run"); // Run the query. echo '<table width="750" border="0" align="center" cellpadding="0" cellspacing="0"> Â Â Â Â <tr> Â Â Â Â Â Â Â Â <td width="205" valign="top">' echo '<br><font size="2" face="Verdana, Arial, Helvetica, sans-serif">Select Project :</br></br>' ......
View Replies !
Dependent Drop Down Lists
I am building a data entry form in php to insert new records into a mysql database. There are two drop down lists - one for the Botanical name and one for the Common name of each possible plant. I need to make the two lists codependent so that if a user chooses by Botanical name, the correct matching Common name will automatically be selected, and vice versa.
View Replies !
Session Info And Pull Down Lists
i have a html pull down list (<SELECT etc etc <OPTION VALUE .....) and i have the particular value the user last chose it to be in a $_SESSION['value']. How do i set the selected item of the list to this one? I can just add it in as the selected item of the list but then it appears twice.
View Replies !
If You're Good With Arrays And Lists, This One's For You
I'm using PHP 4.4.4. Let's say I have two scalars, $list1 and $list2. Both are comma separated lists of ordered, unsigned, unique integers. An example would be $list1 = "2,26,345"; $list2 = "3,4,26,35,525"; I am wondering if there is a short way of determining if all the numbers in $list1 occur in $list2.
View Replies !
Creating Form 'select Lists' Using PHP
Is it by any chance possible to use mysql and php to auto create the content for drop-down lists on forms by retrieving the values from a database? The reason i ask is that on a site i am making i am asking users to select from list (e.g. nationality) however i would like to avoid typing out every possible value of which there are about 40 (which change). I would much prefer to keep a seperate table in my database for the site.
View Replies !
Sorting Alphabetically Backwards Lists
This code runs @ http://www.ckoogle.com but the trouble is once I get the list backwards, and in an array. I can't sort the new array into alphabetical order. Anyone know a way to do it? <?php echo '<form action="index.php" method="post">' echo '<textarea name="input" cols="12" rows="20">' echo '</textarea><br>' echo '<input type="submit" value="Submit">' echo '</form>' if( isset( $_POST["input"] )){ $my_array = $_POST["input"]; $my_array=strrev($my_array); $my_array=explode(" ", $my_array); print_r($my_array); sort($my_array); print_r($my_array); for($cnt=0; $cnt < count($my_array); $cnt++) { echo(strrev($my_array[$cnt])); echo('<br>'); } } ?>
View Replies !
How To Get Hotmail/Yahoo/Aol Contact Lists ?
is there anyone familiar with the part how does most of the match making sites/schedular websites are accessing your Hotmail/Yahoo/Aol address book and even inviting your friends rather choosing one by one from your address book manually by you and make you be in the same Network?
View Replies !
Detecting Checkboxes And Option Lists
I am trying to figure out how to detect a <Form> check box being checked in a PHP script. Likewise, I am trying to figure out how to detect which option was chosen in a <option> list of drop-down items in a form. Code:
View Replies !
Lists The Top Viewed File In The Database
I have the following SQL query: SELECT * FROM file_items ORDER BY view DESC LIMIT 0, 1 This lists the top viewed file in the database. However there's a problem with this. I need to ensure that file is of a certain type. In a seperate table named "files" there is a column named "type". The above query needs to be modified so that these two tables are cross-referenced. Both tables have a column named "id" which could be used to match things up.
View Replies !
Auto-update Shopping Lists
I have a shopping list, or multiple shopping lists, that users and sort and add/delete items from. I know how to add/move/delete items, but that is with a submit button. Is there a way, probably through AJAX, that the mySQL tables will be updated automatically as things are changed?
View Replies !
Building Lists Taking Way Too Long.
This is just a tiny simple bit of code but it takes way longer to run that I think it should. I'm going through our website and trying to cut down the load time (currently 0.5s to generate the page) $start = microtime(true); for($i=1;$i<=31;$i++) { $options .= "<option value = "$i">$i</option>"; } echo $options; echo "Echo day ".(microtime(true)-$start)."<br />"; this code takes 0.07s to run. For what it does, that is redicilous. Interestingly, if I keep refreshing the page, eventually it goes down to about 0.0001, but why? Everything else seems to stay around the same time.
View Replies !
Dynamic Drop Lists For Modify
Hello, I hope this is posted in the correct forum. This is a mix of php and javascript and what I am trying to do combines the two so I hope this is the best place for this post. I have 2 situations, one when adding an employee and the other is modifying the employee. I have a drop list the holds all of the companies that when you select a company, it changes the droplist of departments to show the available departments for the chosen company. So the dept droplist dynamically changes based off the company you choose. I have this working perfectly. THis is for adding an employee. My problem I have now is I need to modify the employee and when you first pull up the form with the employee info, it is populated from a mysql query. The droplist for companies is selected to the correct company, however, the droplist for depts is not because the javascript code I have is set to fill the dept list on an onchange event which on page load does not exist. If they select a different company, my code works fine but when they first hit the page, the dept list is blank because the onchange event has not been kicked off. I realize this is javascript but I am not sure where my changes need to be made. below is my code for the companies and depts only. I will leave out the other employee info becasue it is irrelavent. I will post what I have so far and hopefully you can guide me in the right direction Code: ....
View Replies !
Converting Inc Files Into Linkable Lists
I have a script that reads a directory, strips various parts of the name and creates a list that can be used as links. Unfortunately, the script gives me the following error when I run it: Parse error: parse error, unexpected '.' in /home/hearnofg/public_html/temp/sermons/index.php on line 16 The follwoing is my code:
View Replies !
Pulling Options Lists From Mysql Tables
I've set up a form to load data into my db, but rather than hard code the options lists for three of the form fields, I'd like to pull that information from three lookup tables. This will allow whoever is inputting data to do a simple update for the three lookup tables, and speed enter the data into the form for the fourth (data) table without having to alter the code in the form. Here's the wish list. The three lookup tables have a key field and a description field. I want to display the description field content for selection by the user in the form (for example, from EventClass table, display "Single Pony" and return "1" to the CompClass field if Single Pony is selected Display "Pair Pony" and return "2" to the CompClass field if Pair Pony is selected display "Single Horse" and return "3" to the CompClass field if Single Horse" is selected (etc.) in EventScores), and have the key field content loaded with the data into the data table. Once I've figured the coding for one, I can duplicate the effort for the other two tables. I have seen PHP coding inserted inside php code. I've never seen this particular practice in any other language I've programmed in. Is this how a connect/query is handled inside a form which is inside a php script? <?PHP <form><?PHP ?> </form> ?> ?? To put it another way, I want to retrieve the data from a table and display it in the options box of the form. Then, when a option value is selected, I want the key for that value returned to the table in which data is being loaded.
View Replies !
One Result Set Makes Two Lists With Same Keys And Values
I have a page with two drop-downs, each listing the same employee names and their id's as the values. So they look like: <select name="selection_1"> <option value="12">Curly</option> <option value="8">Larry</option> <option value="36">Moe</option> </select> ....then further down the page: <select name="selection_2"> <option value="12">Curly</option> <option value="8">Larry</option> <option value="36">Moe</option> </select> Currently I am doing this, which works but seems sloppy: <select name="selection_1"> <? while($employees=mysql_fetch_assoc($qry_rslt)) { /* ADD NAMES TO DROPDOWN WITH emp_id's AS THEIR VALUES */ ?><option value="<?=$employees['emp_id']?>"><?=$employees['name']?></option><? /* CREATE ANOTHER ARRAY WITH THE emp_id AS THE KEY */ $emp_list_2[$employees['emp_id']]=$employees['name']; } ?> </select> Then on the second drop-down: <select name="selection_2"> <? foreach($emp_list_2 as $key => $emps) { ?> <option value="<?=$key?>"><?=$emps?></option> <? } ?> </select>
View Replies !
Smarty And Nested Lists - Arbitrary Depth
I started a brand new site this morning, and thought maybe I would use it as the occasion to finally give one of the templating engines a try. Since Smarty is semi-official (it's at smarty.php.net after all), I settled on that one. Code:
View Replies !
|