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.





Selected Value In Dropdown Dependent On Database Value


i need a way to make the selected value of a drop down dependend on a result from a database query. PHP Code:




View Complete Forum Thread with Replies

Related Forum Messages:
Dependent Dropdown
I have set up a MySQL database with 5 tables that are relevent to this question. The first table is for entering records, the second has only 2 foreign keys that join the first and the third together,

the third has a primary key for numerical value and a name column, that is used for the first dynamic dropdown list, the forth table, like the second has only 2 foreign keys to join the third table and the fith table and finally the fith table, like the third table has a primary key for a numerical value and a name column for the planned dropdown menu.

How I can get the first dropdown menu to work, how do I get the second one to run off it and the form or forms need to submit to 3 tables, how do I do that?

View Replies !
Php Dropdown - Selected?
i'm using this to pull information from a database and display it in a dropdown list. The problem is I am using the name code when I goto the "Update" page, but i'm not sure how to add the "selected" field, that way what ever I saved in the database will load.

Example: I goto add and it add's the "id" of 7 to the field, when I load the page again it auto's back to 1 instead of clicking in-to 7 as thats whats already there... = ) Code:

View Replies !
Remember Selected Value DropDown
I am attempting to have a drop down menu that displays url from 1 table called links the same table also contains a name for the url. i.e. google.com = name and http://www.google.com = url The value of just the url from links is stored in a separate table called users in a field named search after form is submitted by user. Everything Posts correctly except when go back to edit the record and submit the form the drop down box does not retain the value of what had been previously selected although it is the correct record until form is updated when whatever value is currently in the drop down list will update the record.

I know the code is doing exactly what it is told to do, because I have no functionality in it to recall the value from the field search in the users table. I don't know if it is something I would have to add to the array or option value. I can get it to work if it is all hard coded, but I am attempting not to do this. I am pretty new to php mysql and any help is greatly appreciated.

This is the code I am working with that came mostly from a tutorial. PHP Code:

View Replies !
Dropdown Menu <selected Name="...
I have a dropdown menu like this one:

<select name="country" tabindex="6" id="select_country">
<option value="">- Country List -</option>
<?php 
$query = "SELECT * FROM country ORDER BY country ASC";
$result = mysql_query($query) or die('Error, query failed');
while ($row = mysql_fetch_array ($result)) {
$country = $row['country']; ?>
<option value="<?php echo $country ?>"><?php echo $country ?></option>

After I have selected one country and I hit the submit button it go back to the default value in the box, what I want is to show the selected value in box until I selected another value.

If the default value is Australia when I start this page, I then select USA and hit the submit button it reset to the default value "Australia", but I want it to show USA as long I not select anything else. I have tried to use session in selected="<?php echo $_SESSION['country']; ?>" but it didnt work.

View Replies !
Print All Selected Items From Dropdown??
I have a program that allows users to select a 'New Graduate' membership, and for each one selected, they get a free tshirt.  I've got that working using a 'is_new_grad' function that I created.  So, if they select 2, they see 2 dropdowns to select the sizes of them.  It then sends an email w/ the membership info and the shirt sizes selected.

However, when the email is being sent, it's only returning the size of the LAST item selected in from the drop-downs.  Example: if I sign up for four of these memberships and select four different tshirt sizes (1 Medium, 1 Lg, 1 XL, and 1 XXL), the info in the email is all XXL: Code:

View Replies !
Dropdown List Selected By Default?
Does any one know how to have an item in the dropdown list selected by default?

$city_field = HTML_QuickForm::createElement('autocomplete', 'city', 'City', $cities);

$cities is an array of city names and I would like, say 'Los Angeles' selected by default.

View Replies !
How To Pass The Value Of Selected Dropdown Menu To Another File?
there is a php-myql script that list the mysql databases in the drop-down menu, use wil select one and the submit button should pass the value or variable $db_name to the test.php, this script list the databases in the drop-down menu but when i select one and then click on submit cannot pass the db_name to the test.php:

View Replies !
Must Database Table Be Called Up For Dependent List Box Form?
I want to produce a form which will post selections named size and drive to to a file blindsize.php. Looking around this forum and the web, it seems that the only way to do this is to set up a database table (I would set up one in MySQL) and call up that with javacript.

If setting up a MySQL table is the answer, then I would probably use this script. But as I am also new to javascript, I would now have a further learning curve with that, though at first glance the script tutorial looks very good.

But is setting up a database table the only way for a php user? When I first started looking around, I had though the way might be a series of elseif lines.

View Replies !
PHP Dynamic Drop Down Menus, Page Displays Diff Data Depending On Dropdown Selected.
I currently have two drop down menus the first one with countries and then the second one changes depending on which country is selected to display counties.

This works fine, now what I want to do is have it so when it county is selected it shows all the squash clubs that are in that county below the drop downs. Code:

View Replies !
No Database Selected
Im running twice the same website:

- one for the public
- one for private testing

Everything is moreless the same, except some config variables in the php and the replacement of css directories. However on the test server im getting a no database selected:

mysql_query('sqlhere') doesnt work
mysql_query('sqlhere',$conn) does work

So somehow on my test server it is not taking the only open connection, but wants it specified. Code:

View Replies !
Database Selected Error
I built a web application for our IT department to handle PC Cases. I used PHP/MySQL for the application. Everything for the most part works fine except every once and a while when you are navigating the pages I get a blank white page with the error "No Database Selected" in the top left hand corner. It seems like the database is timing out or something, or maybe its getting too many queries, I'm just not sure.

View Replies !
1 Record In Database But 2 Records Were Selected?
i'm retrieving a record from database. below the record, i have a yes and no button, where i can let user click and then count the number of yes and no.

everything works fine, but when i start to click the yes or no button, my record ,becomes two records. i only have one record in my database, but two same record was displayed.
this is the code: PHP Code:

View Replies !
Error In Query. No Database Selected
I have an error, not a php syntax error, everything is working fine but I get this error "Error in query. No database selected", does anyone have any idea on how to solve this. 

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 !
No Database Selected - Simple System That Includes Pages
what I've got it a simple system that includes pages the reference to which are in a database. This bit worked a treat. until i tried to put something that did some work in one of the included pages. PHP Code:

View Replies !
Autopopulate Dropdown List From Database
An events-registration page with a form containing a dropdown list for upcoming events, the events will be pulled from a table which is updated by...?

what i've gathered so far is that this can be done with PHP. I am a little unclear on the concept of how this is done. How does the updated information get input into the table?

1) can this be done (updating database) through a web interface by the client, or is it something i would have to do locally and then upload. If done by the client, can he delete/edit existing information--assuming he is not familiar with code.

2) what other things aside from html(good), sql(so-so), and php(newb) will i have to know?

i've seen a lot of good tutorials here and will have access to the necessary software. I just want to know if there is anything else i should know before i dive in head first without testing the PHP water, which i assume is frigid.

View Replies !
Searching Database With Two Dropdown Menu
I have searched the whole forum for the script. Please let me know if there is any script .

View Replies !
Add Data To A Database Using Dropdown Menus?
lets say i had a database with a table called admin hacks and another table called user hacks,and both tables had feilds called name and id

now what i want to be able to do is create a submit form with a drop down menu saying the table names mentiond above, also the form will have a field called name.

now lets say a user slected admin hacks from the drop down menu and enterd jack in the name, how would i get the data in that submitted form to be inserted into the correct database table, so jack should now be in the table called admin hacks

also lets say someone selected user hacks and entered jon how would i do the same for that?

View Replies !
Insert Date To Database Using Dropdown Boxes
I be able to insert the date into my database if i have 3 dropdown boxes wherein it contain the month,day & year. i know the basic of inserting data into my database but with this 3 dropdown box i don't have any idea. after submitting, the data selected on these 3 boxes shall be in one field in my database with fieldname Date.

View Replies !
Duplicates In A Dropdown Menu Populated From My Database
I've been searching to figure out how not to have duplicates in a dropdown menu populated from my database. This is what I have, but how do I change it to get rid of duplicates.

<?php
$result = mysql_query("SELECT City FROM residential order by City");
echo "<select MULTIPLE NAME="City_code">";
while($row = mysql_fetch_array($result)){

echo "<option name="City" value="$row[City]">$row[City]</option>";

}
?>
</select>

View Replies !
Make Selected Option Stay Selected In A Combo After Submit
I have 3 comboboxes, one for the day, other for the month and another one for the year. Every time i select a value for the three of them and press the "Submit" button, they reset to the default option. Anyway this can be solved?

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 !
Dependent Includes?
i've got a page someone else built with an include for another file. the include needed a random banner, both jpeg and swf.

so i figured that one out - i've set up an include in that file which calls the proper code randomly from a text file, one line with the embed for the swf and one line with the image (both in their own link tag - a href...)

so here's the issue -

back on the top level, there's another banner which needs to be dependent on the include inside the include.  they're in 2 completely different places, so tying them into the same file is not an option.

View Replies !
If Else Dependent On Variable In Sql
I am trying to have php talk to sql and depending on if there is somthing in the db have it display one image or the other.

I have filesize default to 0 if nothing is put in. I have no idea what I am doing and after hackin' this for the better part of 3 days. Code:

View Replies !
Dependent Drop Downs?
I have a drop down menu populated from a database. There are 3 other drop downs on the page that I want to populate from the database AFTER the user has made a selection in the first list. Can that be done? Are there any scripts for that anywhere?

View Replies !
Dependent Select Menus
I would like to create a form in which a 2nd select box appears
depending on the value selected in the 1st select box. The values of
the 2nd select box will come from a database.

My question is how to create this in php? One way is to re-load the
page depending on what's chosen in the first box, or alternatively to
use frames or an iframe?

Is there another, better way that can dynamically change the initial
page?

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 !
Dynamic Dependent Drop Down Boxes
I need to build a dynamic page with 2 drop down boxes on it where the contents of the second drop down box are dependent upon the selection made in the first drop down box (the first box contains districts/regions and the second box contains towns/cities). The customer wants this to happen on a single screen but can this be done with PHP?

View Replies !
Substr With Dependent Length Parameter
Is it possible to use substr() to get only the letters displayed after numbers (at the end of a string)? For example:

WA-0318a would give me a
SAN-2011Aa would give me Aa
KE-2200Eb would give me Eb

So, if $variable = "SAN-2011Aa" then substr($variable, -?). The negative length parameter would be dependent on how many of the ending characters are letters and not numbers. In this case, I would need to dynamically generate 2 (for -2). In the case of "WA-0318a" I would need to dynamically generate 1 (for -1).

Is this possible?

View Replies !
Loading Image Dependent On Category
We have created a small PHP script which will load a particular image dependent on which category the blog is posted in. On our website index (index.php) we have the following codes:

View Replies !
Sending To A Second Email Dependent On Checkbox Value
I have searched this board and others, I have looked through my books and I can not figure this out. I have tried at least a dozen variations and none of them seem to work. I have a form that is on an html page.

When the user submits it, it sends an email to person 'A', but if they select a checkbox then a copy has to also go to person 'B', but only if the box is checked. I figured I could just put the php in the form to create the hidden input, not getting it. Code:

View Replies !
Detect What Option The User Selected And Then Direct That User To The Selected Page.
Quick question regarding HTML forms and select fields. I want to be able to detect what option the user selected and then direct that user to the selected page.

<select>
<option name="1">1.html</option>
<option name="2">2.html</option>
</select>

when the user selects, 1.html, it'll direct them to http://www.domain.com/1.html same with 2.html. I wasn't sure if this was done with PHP or Javascript, if its possible on both, which is better?

View Replies !
Passing Multiple Variables From Dependent Drop Downs
I have a drop-down menu that lists 25 items (vips), when selecting one item (multiple= "no"), the page reloads and opens another dropdown menu with 20 items (Servers) (multiple= "no").

When the user selects a server from the 2nd drop down, the are asked to complete a final action (two radio buttons) either "on" or "off".

Based on this final selection the user is taken to a new page and a script is run to turn onoff the server they selected. Code:

View Replies !
Multiple Selected="selected" In A List.
I have a database with 1 to many and the many is a list with multiple
selects in a list. When I click on a master record I have as part of
my form the select statement for the multiple choice list. I want the
list to highlight the multiple chosen values. here is part of the
code.

$dresscat = specdresscat($dresstypeid); //this is the query to get the
values in the detail table
$drcatrow = pg_fetch_array($dresscat);// the array for the detail
table.
<select name="stages[]" multiple="multiple">
<?php
$allstages = allstages(); // this is a function to query my database
to get the value for the list.
while ($allstagerows=pg_fetch_array($allstages)) {
$eachstage= $allstagerows["stageid"];
$specstage= $drcatrow["stageid"]; // this is the point I need help
if ($specstage == $eachstage){ ?>
<option value=<?php echo $eachstage;?> selected="selected"><?php echo
allstagerows["stage"]?></option>
<?php }else{ ?>
<option value=<?php echo $eachstage;?>><?php echo
$allstagerows["stage"]?></option>
<?php
}
}
?>
</select>

View Replies !
Selected Value
Trying to get the below to have the SELECTED value chosen but it is not working. What am I doing wrong?

while ( $buyerline= mysql_fetch_array($getresult, MYSQL_ASSOC))
{
print "<option value='$buyerline[id]'".($buyerline[id]=='$buyer'?' SELECTED':'').">$buyerline[buyer]</option>
";
}
print '</select>'

View Replies !
$selected
I'm trying to generate a select box through php. the problem comes when I try to dynamically add in the 'selected' attribute to one of the options. My script is basically the following: Code:

foreach($values as $key => $value) {
if ($key == $checkVar) { $selected = ' SELECTED' } else { $selected = '' }
$options .= '<option value="'.$key.'"'.$selected.'>'.$value.'</option>'
}
print '<select>'.$options.'</select>'

View Replies !
Selected Box Action
how to set the respond to action when user choose an option inside a <select></select> box? eg. when user select an option in the <select> box then php search for data inside mysql and then display the required data on the <input type=text>.

View Replies !
Know Out Of All Checkboxes How Many R Selected And Which Are They?
i have a checkbox array of some unknown size.its a dynamic array created.
i want to know out of all checkboxes how many r selected and which are they?
and then insert the data in the table based on that. i hav written the code as follows:-

<?
$no=0;
$friendname= $_POST['friendname'];
$storecount=$_POST['storeid'];
while($no<$storecount)
{
   if($friendname[$no])
   {
      $sql = "INSERT INTO groupfriends (groupid, username) VALUES ('$stid[$no]', '$friendname[$no]')";

      $result = mysql_query($sql) or die('Query

failed. ' . mysql_error());
   }
   $no=$no+1;
}
?>

i dont think this will work.it will add all the checkoxes data to the table. i want to insert only of those which r selected.

View Replies !
Remember Selected
How does a script remember selected qty when the user needs to edit an order form.

echo"<select name ='blar'>";
for($num;$num<$num2;$num++)
{
echo"<option value = '$num'";

........................... // here needs to be selected = 'selected' at the correct place??

echo">$num</option>";....

View Replies !
Selected Combo Box
i have the following code and i am having problems with setting the combox to select the value that is stored in the database. i am hoping that the combo box selects the value and the value from the database is stored in $title PHP Code:

<?php
function displayedit($id,$title,$fn,$ln,$instit,$depart,$email,$url,$room,$phone) {  
echo '
  <form name="editform" method="post" action="editform.php">

  <p class="body"><b>Title:</b>'

    $t ="Dr","Professor","Mr", "Ms"
    echo "<select name='selectTitle'>";
    foreach ($t as $value) {
     echo "<option value="$tvalue"";

View Replies !
Selected In A Drop Down
I have two drop down menus. First one is location. When you change location page refreshes and comes with the selected area. So with the refresh,the second drop down changes to the sub-locations of the selected location. For example: Here is my code:

<?php
if ( ! isset($location) ) {
$location="Bodrum";
}
@mysql_connect ( "localhost", "root", "passwd" ) || die ("MySQL'e baglanamadim");
mysql_select_db ( "ceyhun" ) || die ("Veritabanýný seçemedim");
$sorgu=mysql_query("Select *from locations");
$sorgu2=mysql_query("Select *from sublocations where Location='$location'");
?>
........

View Replies !
How To Give A Value To Non Selected Checkbox
I would like to get a value for a non selected checkbox in a form.

Imagine my form contains :

<input type='checkbox' name='t[0]' value=&#391;'>
<input type='checkbox' name='t[1]' value=&#391;'>

When I analyse $t, if first checkbox is not selected and second is, I have :
$t[0] has no value. $t[1] equals 1
and count($t) equals 1

I would like to find a way to get :
$t[0] equals 0. $t[1] equals 1
and count($t) equals 2

View Replies !
Resize Only Selected Images
I have an image upload script that is resizing every image that a user uploads.
What I would like to do is have a check box added to the upload form that a user can check to resize the image if they want to or leave it unchecked to just upload the image.

So if the box is checked the original image gets uploaded and a resized image is created as well If the box is not checked just the original image uploaded. I tried adding a check box but every image still was resized - checked or not - Im assiming because it was in the foreach loop so I dont know what to do. Code:

View Replies !
PHP And A Pre-selected Option In A Form
I've got a little text editor thing on my site, and to open a file, you input the file name and choose the folder from a drop-down list and click the Open button. The default filename is "index" and that file keeps track of all the files contained in that folder. It works okay. What's annoying is that regardless of what folder you're messing around in, the drop down list always goes back to showing the default folder name as the page is reloaded. I want it to be preselected to the folder it's in.

It seems simple enough--the folder you're in is $_GET['dir']. But I've read some HTML form how-tos, and I can only see that you can preselect using the tabindex="" or selected attribute.

View Replies !
Radio Button Selected
What I wish to do is have a radio button pre-selected depending on what is pulled from the database.

For example if I had 2 radio buttons:

o Yes o No

One has the value 1 and the other has the value 0

If 1 is selected from the database then Yes is pre-selected, else 0 is pre-selected. How would I do this?

View Replies !
Setting Selected Option Using PHP
I have a drop down list which I want to be set to what was selected when the form is submitted. As the form is processed by the same page, it returns to the preset default. How would I go about making this selection box set the option selected on the next page?

View Replies !
Randomly Selected Account
I have an application that I need users to be logged into automatically without creating an id. I have setup a database with users names as user1, user2, user3, and so on, and a field called in_use. I can make php set the in_use field in the database to yes when the page is loaded and I can get php to select the first available username. I can't however get the database to reset the in_use field by itself (if the user closes the window insted of clicking log out).

View Replies !
Display The Selected Checkbox Id
I created a list of check box,if i select a indvidual check box,then it must go to the indvidual pages on the basis of selection. how to code for this.

View Replies !
Want To Add A Re-direct When Submit Is Selected
I'm using this Upload script and would simply like to re-direct the User, after he's Uploaded, to a different location. I don't know where/how to do it? Code:

View Replies !
Jump Menu Selected Value
I have a set of 2 menus where the values of the 2nd are dependent on the value selected in the first. Yes, I will (eventually) convert this to a javascript process, but for now I am content reloading the page.

I have created a jumpmenu that reloads the page with the state passed in the url (ie. community.php?state=NY). This determines the values displayed in a second (dependent) menu which then lists the counties available for that state. Code:

View Replies !
Collecting Selected Options
how I can achieve the following:

Page1

Within form is a list of 100 questions each with their own checkbox, however the user must select to answer only 10 of these questions. So they select the 10 questions they wish to answer.

Page2

Then display the 10 questions they selected.

I believe this is something straightforward,just i cant get started.

View Replies !
Selected List Item Value
I know that the value for each element of my form is available through $_POST 'element_name'] but this doesn't work for lists. Can anyone tell me how I refer to the item selected in a list (combo box)?

View Replies !

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