Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP


SuperbHosting.net have generously sponsored dedicated servers to ensure a reliable and scalable dedicated hosting solution for BigResource.com.





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 Complete Forum Thread with Replies

Related Forum Messages:
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 Replies !
Dropdown Lists From A Mysql Db
Id like to load a drop down list from a mysql database using php3 and create a link to that record. Does anyone have any ideas?

View Replies !
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 !
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 !
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 !
Auto Populate Dropdown
How would I automate this script below so that I dont have to modify it each year (example; when the year reaches 2008)

<?
// Make the years array.
$years = range (2007, 1930);
// Make the years pull-down menu.
foreach ($years as $value) {
echo "<option value="$value">$value</option>
";
}
echo '</select>'
?>

View Replies !
Auto Fill Dropdown List Error
Im using the code below to autofill a dropdown list from my MYSQL DB.
The only problem is it is leaving out the first entry (alphabetically) for each $vehicle_make ? Does anyone know why this may be hapenning? Code:

View Replies !
Auto Fill Date Dropdown List
How would I modify this code to display the years in the dropdown list like so:

current year
2006
2005
back 50 years

<select name="year" id="year">
<?PHP

for($i=date("Y");
$i<=date("Y")+2;
$i++)
if($year == $i)
echo "<option value='$i' selected>$i</option>";
else
echo "<option value='$i'>$i</option>";
?>
</select>

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 !
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 !
Get Dropdown Values
I am having trouble getting the values from a dropdown <SELECT>list and using the selected value as a part of my SQL statement. Code:

View Replies !
Dropdown Select Option
I've sort of hit a roadblock. I'm working on a user system using PHP and MySQL. Where I'm stuck is on the "Edit User" page where the admin or user can go in and change the personal information of a user. Here's the dropdown menu.

<SELECT NAME="NameSuffix">
<OPTION VALUE="">SUFFIX</OPTION>
<OPTION VALUE=""></OPTION>
<OPTION VALUE="Jr.">Jr.</OPTION>
<OPTION VALUE="Sr.">Sr.</OPTION>
<OPTION VALUE="M.D.">M.D.</OPTION>
<OPTION VALUE="Ph.D">Ph.D</OPTION>
<OPTION VALUE="I">I</OPTION>
<OPTION VALUE="II">II</OPTION>
<OPTION VALUE="III">III</OPTION>
</SELECT>

<?php print("$data[6]");?> Gets me the database value from the NameSuffix field. Let's say, for example the value is "Sr.".

View Replies !
Retrieve Values In Dropdown Box
I would like to retrieve values in drop down box from database table. It should be the date value. The date is stored as 'yyyy-mm-dd'. I would like to retrieve , yyyy, mm, dd seperately in a drop down box. Ihow i can make it.

View Replies !
Values From DB Into A Dropdown Menu?
Here's my database which shows which type of cards have been issued to a football player in my database: Code:

View Replies !
Query From Db, Add Values In Dropdown Menu
i wanted to query my db, and then add values to drop down menu, where when they select what they want in the dropdown, it will bring them to another page accounts.php where they will have more options.

View Replies !
One DROPDOWN SELECT Control Can It Fill In 2 Textboxes?
I have a form with text boxes and a dropdown menu with names of cities
The adjacent textbox fills by the help of a Javascript function.
My question is, how to realize the purpose of filling the adjacent texbox
for zip values. Code:

View Replies !
Pass Values Of Dropdown Boxes Into Variables.
I have a form I am creating, it has a total of three drop down boxes the first gets its info from the database the second is just static, and on the second drop down box I have added an on change event which calls a function, like this.

<select name="names" id="region" onchange="getregion()"

First question is, will that call a function in PHP? Second question is the function I need to write must have the values of the first and second text box, do you have to post this data to pass them into variables?


View Replies !
Auto Select
PHP Code:

// 1) Get all Investment Types
$query = "SELECT investment_type_ID, investment_type, inv_note, inv_note2 ".
           "FROM investment_type";
$result = mssql_query($query) or die('Select Error');

View Replies !
Auto Select Field
I have a contact form in php and want the first text field to be auto selected, my field is called 'First' id= First. is this php or java script?

View Replies !
Auto Selecting A SELECT
I have a taxation rate for different users stored in mySQL. Based on the user that is logged in I SELECT the tax rate for the user's session.

I have a <OPTION> <SELECT> drop down which has a list of taxation rates.. the values can only be 1, 2, 3, 4 and 5%. How do I make it so that the taxation rate of the user is SELECTED by default in the drop down menu? Code:

View Replies !
Make A Dropdown Option Field For User To Select Date?
how can make a dropdown option field for user to select date?

View Replies !
Auto Increment Values
Where do I go to find out what values my information has been auto incrimented? I don't see anywhere how to find what number each thing I put in there is assigned.

View Replies !
Auto-setting A Select Drop-down
I have 3 select menus for dates, I need to be able to auto set (on load) which number in the dropdown is selected, for example, if the date I pass to the page is this:

01/15/2007

I would use explode("/", $date) to get each number, I know for a fact that the format will always be (month)/(day)/(year), so no worries with that, but then how would I make it so that January is selected automatically, as is 15th, and the year 2007, in the drop-down menus?

View Replies !
Form Auto Select Option
I have a website that has a contact form with a dropdown list of names. I would like to code it so that when a user selects a person's name from another page, that when it brings them to the contact form, that name is automatically selected in the dropdown list.

View Replies !
Auto Increment Non Numeric Values
I have a string with a line of alpha-numeric values. I want a function to take the previous value u and then increment it by one, in order of the string. So, if the string was "1234567890abcdefghijklmnopqrstuvwxyz", 1 goes to 2, 0 goes to a, and z would go to 11. But endlessly so something like dw34fz would go to dw34g1. If anybody has anything that can do this.

View Replies !
Identifying Auto Increment Values For Each Of The Fields
I have set up a database i mysql, identifying auto increment values for each of the fields (eg AdminID). I was wondering how i can set up a form which will, when i go to add a new member, have the autoincrement value already present in the field and i can continue to input the rest of my data as usual.

View Replies !
Having A Little Trouble With PHP/MySQL Duplicate Auto-increment Values
I wrote some code to store some values in a table to dynamically display ads on the right column of my site. This code allows you to organize their order, remove, update, etc... In order to do this, everytime there is a change made to the layout, I first delete all the records for the current page then I re-insert everything.

The problem is, that on rare occassions this fails because the auto-increment value of the primary key eg. 127, is already in the table taken by another record.

I should mention that the id field (primary key, auto-increment) is never manually inserted, I always pass a blank value for auto-increment to take care of it.

Is this some kind of MySQL bug, or could it have something to do with my DELETE before inserting again?

View Replies !
Selecting Current Month In Month Select Dropdown
I have set up a simple dropdown to list all the months a year from now and for the past year, so form July 2006 - Jun 2008. However, I am looking to have the current month as the selected option when the user first sees the page. Any ideas on how to do this? Code:

View Replies !
Getting All Select Box Values
I'm running into a problem with a select box. Its values in PHP are not properly parsed.

<select name="frm_owners" size="10">
    <option value="1">Apples</option>
    <option value="2">Oranges</option>
</select>

Now, if I were to select both options and then output $_POST[frm_owners] on another page, all I would get is "2." But I'm looking for a comma-seperated value like "1,2." Any ideas?

View Replies !
Select 5 Different Values
write a select statement that would randomly select 5 different values from lets say 6 of them in total. the reason is that im sending emails to users but i dont want the same email to show more then once.

View Replies !
Get <select> Values
I'd like to ask how to get <select> value via PHP? (not through submit) for example:

<select name="testPHP">
<option value="entry 1"></option>
<option value="entry 2"></option>
<option value="entry 3"></option>
</select>

I want to add an event handler "onChange" such that every time I change the selected value (not submit yet), I can pass what I selected to another function for further process (query mysql server and etc.).
I know it's quite easy to achieve via javascript (onChange="function(this.value)"), but how to achieve the same effect via PHP.

View Replies !
Getting Values From <select>
How do I get values from <select> into php?

html:

<select name="genre" id="genre">
<option value="Yo Mama" selected>Yo Mama</option>
<option value="Blonde">Blonde</option>
</select>

php:

$genre =$_POST['genre'];

Whats wrong. My script also displayes what has been selected and it always shows: "Genre: " and does not say the genre.

View Replies !
Form Select Values
I need to pass values from a form that includes this drop-down selection:Code:

<select name="$searchby">
<option value="null"> Select one
<option value="a.name"> Name
<option value="a.addr" > Address
<option value="a.zip" > Zip code
</select>
to a php/mysql querry where it will serve as the column identifier in a WHERE statement:
Code:
SELECT a.name, a.addr, a.zip from table
WHERE $searchby like '$search%'

I have the "$search%" variable passing fine, thanks to folks on this board. When I try to make the column variable, though, I'm getting "Check for... right syntax to use near 'like '%' ". I've read manuals, searched Web and tried several other approaches to get the column variable passed but to no avail. It seems I need to set up an array, but I get an sql error that tells me something like there is "no column named array".

View Replies !
Redisplaying Select Box Values
I tried different variations of redispalying submitted select values to no avail.Can anybody tell me what's the best option to achieve this?

<select name="options">
<option value=$option1 SELECTED>option1</option>
<option value=$option2 SELECTED>option2</option>
<option value=$option3 SELECTED>option3</option>
</select>

I even tried a code posted by Hakre back in 2005,but it gave me a parse error:

Parse error: parse error, unexpected T_STRING, expecting ')' in ...

Hakre's way:
<form action="mypage.php">
<select name="selbox" size="1">
<
...

View Replies !
Retrieving Select Values Using Php
how can we read a select value in a html page that a user selects in a form using php and later how to insert that value into mysql database.

View Replies !
Multiple SELECT Values
I have a select "List" box where I am selecting multiple items by holding down CTRL.

<input name="prod_id" type="SELECT" multiple>

--SEPERATE FIELD--
<input type="hidden" value="12321" name="package_id">
^^ That Type ^^

So I am trying to add multiple rows as follows:

PHP Code:

View Replies !
Values From Multiple Select
PHP Code:

//gets listing of areas for Detailed Search when doing listings search;

            $query_area_search = 'SELECT DISTINCT(a.description), a.value '
                . ' FROM areas a'
                . ' WHERE a.value NOT LIKE &#390;''
                . ' GROUP BY a.description'
                . ' ORDER BY a.description ASC'
            $result_area_search = mysql_query($query_area_search);
while ($row_area_search = mysql_fetch_array($result_area_search)) {
                echo "<option value="".$row_area_search['value'].""";
                    if ($row_area_search['value'] == $_POST['areas']) {
                        //$selected = " selected ";
                        echo " selected";                    }
                echo ">".$row_area_search['description']."</option>

View Replies !
Select Distinct Values In Only 2 Columns
I have a table where a customer may have multiple accounts.

I want to eliminate duplicate values for Customer_ID and Account_ID -- regardless of their state or region.

I tried this,

SELECT (DISTINCT Acct_ID, Cust_ID), Address, City,State, Zip,Country, Contact, State_ID,Region_ID,
FROM t_table

but it doesn't work.

This (below) does work, but it gives 2 records. One record when a person is listed once in a target state, and a second record if that person is listed in an overlapping region.

SELECT DISTINCT Acct_ID, Cust_ID, Address, City,State, Zip,Country, Contact, State_ID,Region_ID,
FROM t_table

(this is the same as)
SELECT DISTINCTROW Acct_ID, Cust_ID, Address, City,State, Zip,Country, Contact, State_ID,Region_ID,
FROM t_table

Is there any other way to select distinct values in only 2 columns?

View Replies !
Randomly Select 5 Different Values From A Database
i want to randomly select 5 different values from a database, from one table, and then just assign those values to some php variable.

View Replies !
Excludling Multiple Select Values
select query joining a large table has:

SELECT DISTINCT State, StateCode, McountID AS mtfkparam
FROM commercial LEFT JOIN Mcount on (Mcount.MCountFIPS = commercial.CountFIPS AND McountID = 'X')

WHERE (StateCode!= 'AS') AND (StateCode!= 'AA') AND (StateCode!= 'AE') AND (StateCode!= 'AP') AND (StateCode!= 'FM') AND (StateCode!= 'MP') AND (StateCode!= 'PW')ORDER BY 'State'

Here 'X' is simply equal to a session variable. Is there a faster way of executing the 7 WHERE (StateCode!=.... 'StateCode's are in table 'commercial' which also has CountFIPS // county codes

View Replies !
Increasing Numeric Values Without SELECT?
I want to track a lot of site statistics and I remember there is a syntax that allows to increase a certain value in a database with just an UPDATE command but don't remember how it looks like

does anyone know? I need to update several entries sometimes and I don't want to ruin the execution time by reading and writing several entries with php code.

View Replies !
REQUEST Values From SELECT Multiple?
I've got a <select multiple='multiple'> input on a php page. and I'm not sure how to get the values back if I select more then one option.

View Replies !
Adding Multiple Values In Select Box To Db
Does anyone know how to add multiple values from a select box to a mysql table?

Here's the code I'm trying to use to add multiple values:

foreach ($_POST['section_id']) {
$sql3 = "UPDATE $table_name13 SET
date_id = '$_POST[date_id]',
section_id = '$_POST[section_id]'";

$result3 = @mysql_query($sql3,$connection) or die(mysql_error());
}

Of course, this is not working. Anyone have any thoughts on how I might do this using PHP?

View Replies !
Inserting Multiple Select Values
i have a multiple select box which i'm using to get values for a field in my table. Now on my insert page i have this PHP Code:

if (isset($_POST['other_room']) && is_array($_POST['other_room'])) {
  foreach ($_POST['other_room'] as $value0);

in my sql insert i have INSERT INTO residential_properties VALUES ('', '$value0', ) etc.

View Replies !
Moving Values Between Select Boxes
I am Moving Values Between Select Boxes using the following code snippet Code:

View Replies !
Population Select Menu Using Php And Database Values
I have no idea how to go about this. so i would apreciate some help i want to populate the values in a html select menu from database values in one table

so i want all the values from 1 particular field in the database to be displayed in the select menu as separate options.

View Replies !
Save Values Off When Select Link Back
I have the form values set to value="<? php echo $Name ?>".

I need to allow a person to access a presentation from within this test form if for example they are unsure of an answer they can return back to the presentation.

I need to retain what they have answered on the form b4 they choose to go out to presentation when they come back. If they only use the back button, values are retained but if they reselect to take the test, I loose all.

I need to save values off when they select link back. Can anyone give me an easy way. I guess I could write to D.B. file with save values and read back in but is there a simpler way?

View Replies !
Popup Window List Of Values To Select
What i need to do is bring up a popup window with a list of values(values looked up from the database). The user should be able to select one of the values from the list and the value then populate a text box on the calling form.

View Replies !
Convert CSVs To Select Option Values
I was just wondering if someone could point me to a good web resource that could help me figure out how to convert a string of comma separated values (being pulled from a database) into a select menu (pulldown box) so that the values from the CSV would automatically fill in the displayed text area of the option tags as well as the value attribute so the value selected could actually be passed as a variable.

I imagine it has something to do with converting the CSV list into an array using substring parsing & then dynamically building the array from the elements of the array, but I just haven't been able to put it all together yet. If anyone is familiar with anything published on the web that might help, I'd be deeply appreciative.

View Replies !

Copyright © 2005-08 www.BigResource.com, All rights reserved