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 Complete Forum Thread with Replies
Related Forum Messages:
Selected Value In Drop Down Menu
I want the first option ("selected" option) in a drop down menu to be based on the URL a user clicks on. For example, if the user clicks on the link: layouts.php?submit=true&category=abstract The first and selected value in the drop down menu should be abstract Then the rest of the menu will pull from the database. The code I am using now (below) lists all my categories from my database, but it is not putting the selected value first. How can I get this to work?? Code:
View Replies !
Showing What Was Selected In Drop-down Menu
I'm trying to create a form where the user inputs data, i validate it with php, and if some of the input is missing or invalid then i print out errors with the form filled out with the information they entered/selected previously so they can change/add to it. The problem I'm having is setting my drop down menus to be selected when the form is returned instead of returning their original state. The menu I have is named A ($A). Here's an example of what I'm doing that isn't working: PHP Code:
View Replies !
Drop Down Boxes Selected Value Against Variable
I have some drop down boxes being populated from a table: print"<td><select name=project>"; if($project=mysql_fetch_array($pro)) { do{ print"<option value='$project[proj_name]'>$project[proj_name]"; } while($project=mysql_fetch_array($pro)); } else{} Now my question is, how can i make the value that is selected equal to another variable ie: $myrow[project], upon loading. Any ideas?
View Replies !
SQL Query Selected From A Drop Down Menu
I've got the following query which gets values $search and $furn from a form. SELECT * FROM properties WHERE description LIKE '%$search%' AND furniture='$furn' ORDER BY id ASC LIMIT $start, $display" This works almost fine. The only problem is that because $furn value is either 'yes' or 'no', selected from a drop down menu, sometimes when is not selected the query doesn't work. Code:
View Replies !
Using Variables To Control What Is Selected In An Drop-down Menu?
I have a drop-down menu with the states. I don't necessarily want to have the menu dynamic with a database, but I want to be able to control what is selected using a variable. Code: <select name=state id=state> <option value="" selected>--</option> <option value="AL">Alabama</option> <option value="AK">Alaska</option> etc... </select>
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 !
Show Selected Value For Drop-downs In Dynamic Menus
I frequently work with forms where menus are pulled from a database. When a user enters data in the form and then saves it, if it is retrieved later, the form shows the saved data, including the drop-down menus. The way I normally do this in php is to first retrieve the data for the saved from. Then I create the menus and within the loop of creating the menus I simply add the word "selected" into the results row which equals the saved option on the form. Code:
View Replies !
Drop Down Menu - Every A Value Of It Is Selected To Reload The Page And Submit That Value.
i have a drop down menu and i want every a value of it is selected to reload the page and submit that value. i'm using something like this: HTML Code: <select name="menu"> <option selected value="1">GENERAL</option> <?php while ($cat = mysql_fetch_array($q)) { $cid = $cat[0]; $cname = $cat[1]; echo "<option value='$cid'>$cname</option> "; } echo "</select>"; i tried using <select name="c" size="1" onChange="MM_jumpMenu('parent',this,0)"> but i got confused so i'm looking for an alternative way..
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 !
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 !
Drop Down 2 Echo Seletion On Drop Down 1
I would like to put up a list/menu drop down so when you select something it echo's something in the second drop down. Example Drop menu 1 ----------------------- course 1 course 2 Drop menu 2 ------------------- If course 1 echo course 1 dates. If course 2 echo course 2 dates Does anyone have an example for me or what do I need to search for cause I don't quit know what it is called and thus I cannot find anything on Google.
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 !
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 !
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 !
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 !
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 !
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=Ƈ'> <input type='checkbox' name='t[1]' value=Ƈ'> 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 !
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 !
Get The Data For The Selected Item And Not The First It Comes Across?
I use the GROUP BY command in one of my queries, the trouble is although they share a common field sometimes the data differs in other fields for an individual record. Is it possible with the command to get the data for the selected item and not the first it comes across? For instance if the data is this ID, Cat ID, Name, Data 1, 1, Name 1, bla bl1 2, 1, Name 2, bla bl2 when grouping by cat id and group concat the name, irrespective of the id that is input to the database the query will deliver. Cat ID: 1 Name: Name 1,Name 2 Data: bla bl1 What I want is for the query to output 'bla bl1' when the id on the php page is 1 and 'bla bl2' when the id on the php page is 2. Is this possible? If the way I've explained it is confusing let me know and I'll try to make it clearer.
View Replies !
Multi Select Box Selected
i have two tables: staff ------------ stid, staff 1| lien 2| tony 3| tom 4| henry bill ---------- billid, stid 1| 1,3 i need for it to display all the staff from the staff table in a multiselect box then have the staff in the bill table selected. i can't figure out how to do this. Code:
View Replies !
Sorting Selected Data
I have a script that retrieves data from a database. Now I want to sort these informations by name, date etc... So, the question is how can i sort already selected data? Code:
View Replies !
Display Selected Records
I have a table on a form which contains records that can be multiple selected by checkboxes. A submit button sucessfully sends the record IDs of the checked records to the next page. I want to display the records that were selected via the checkboxes, but the problem is that I get only the first of them.
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 !
Outputting Selected Option
Given a dropdown form how can I output the selected option when the submit button is pressed. Box: [red ] [submit] [green ] [blue ] [orange] so the user selects an option from the dropdown menu, which is highlited then they press submit, I want to display red, green, blue or orange, whatever was submitted.
View Replies !
Display Emails Once Selected
I have an admin area where i can send emails to any selected member using using checkboxes. On submission it sends you to the next page where the email is then sent. All the emails that have been selected are then displayed Code:
View Replies !
Showing Selected Parent
In my CMS, I have parent and children categories in one level and in one table (id, name, subcat). What i would like to do is, in PHP of course: Upon editing a category, in a dropdown box, show selected, the parent of the category. if there is no parent, show selected, a message saying "Not a subcategory". In the selection though, still shows the parent options as possible selections. } Can anyone help show me the right direction I need to go with this? Do I need a join in my sql or do I need multiple sql queries? Moreso, how do I accomplish this after the query is completed? I am not sure how to go about this.. Code:
View Replies !
How To Tell If Randomly Selected Account Is In Use?
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 !
Saving Selected 3 Combobox
I'm newbie also in php I really need help with this. Code: <? if($_POST['Submit']){ ////////////////////////////////////////////////////////////// // $uploadpath = 'image/' $dbhost = "localhost"; $dbusername = "root"; $dbpassword = ""; $dbname = "ecard"; $db = mysql_connect($dbhost, $dbusername, $dbpassword); mysql_select_db($dbname, $db) or die("ERROR: Cannot connect to the database"); foreach ($_FILES["userfile"]["error"] as $key => $error) { if ($error == UPLOAD_ERR_OK) { $tmp_name = $_FILES["userfile"]["tmp_name"][$key]; $name = $_FILES["userfile"]["name"][$key]; //$valuesel = $_POST["menu"]["name"][$key]; move_uploaded_file($tmp_name, "image/$name");
View Replies !
POSTING Selected Fields Only
I have an orderform with nine product items which is created from a database of those products. One of the fields created is a Quantity field (qty) that allows the user to enter how many of each product they want to purchase. I want to post the order to the next .php page where the items will show on a final orderform with $price * $qty = $totalprice but want to send only the products where a quantity has been entered on the previous page.
View Replies !
|