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.





Dynamically Selecting Default From Dropdown


I have a dropdown menu with 17 options that I want to use to edit a mysql entry. Before I edit it though I want to load the value of that particular mysql column as the pre-selected value in the drop down. Whats the best way to accomplish this. I figured I could write 17 if than statements but thats seems a bit tidious especially if I have more then 17 options. I'd preffer to have the code written out for the options and just add in the selected statement if possible. PHP Code:

<select name="country" id="country">
                <option value="1">CAN</option>
                <option value="2">USA</option>
                <option value="3">RUS</option>
                <option value="4">CZE</option>
</select>

If the result for country = 1 I'd like to add the selected code to the option.




View Complete Forum Thread with Replies

Related Forum Messages:
Dropdown - Default Value
I want to be able to have a drop down list that doesn't necessarily have the first item as the default. The content is being populated by PHP so I have no idea how to do it.

View Replies !
Setting Default For A Dropdown
I use this bit of code to create a dropdown menu for the number of days in a month: PHP Code:

<?

for ($day=0; $day<=31; $day++) {
    echo "<option value="$day">$day</option>
";
}
?>

I want to set the default value to "14" though. How can I do that?

View Replies !
Dropdown List - Trying To Get Default Populated From Db.
Nooby question but when I try and get this to work (it should identify which
rows in the database have GK, MID, DEF, FWD against them and then put
SELECTED into the option value to give a default of what the entry is
currently) it just adds SELECTED to all the results as if $row["Position"]
is returning true against all four conditions? What am I doing wrong? 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 !
Dropdown Not Selecting From Db
when I then goto edit a record, the selection from the dropdown is not selected from value in the db, it always shows Code:

View Replies !
Selecting Initial Value On A Dynamic Dropdown Box
I have a drop down box and am trying to figure out how to select the initial value from the results of a query on my page. Code:

View Replies !
Selecting Item In Dropdown Menu
Im having problems trying to select a specific option in the drop down menu which has been populated with a list pulled from the 'category' table in the db. The option that needs to be selected is pulled from an id in a 'item' table, relating to the aformentioned category table.

View Replies !
Dynamically Selecting Option
I am creating a member edit page, I have 3 select boxes on this page. 1 of the options in each select box will be stored in the database. This member page will be a dynamic page dedicated to the member the user clicks on. Hope I haven't lost you yet (I tend to do that) Now this is an example of one of the select statements.

option 1
option 2
option 3
option 4

Now if option 3 is what is entered into the database I would like that to be showing when the user clicks the page. So the option in the database I would like to be the default option.

View Replies !
Use Strcmp To Edit A Dynamically Generated Dropdown...
I've written a code that runs a 'SHOW DATABASES' query on my mysql server and lists the results(the names of the databases on my server) in a dynamically generated dropdown box, and it works just fine, using the following code:

echo "<select name='databaseselect'>";
$dblist = mysql_query('SHOW DATABASES');
while ($row = mysql_fetch_row($dblist)) {
echo "<option value='$row2[0]'>$row2[0]</option>";
}
echo "</select>";

The problem is that it lists ALL of the databases on my server - that's two of my own user-created databases, and the two default databases that come with the mysql server - 'information_schema' and 'mysql'.  What I want to do is to, after running the 'SHOW DATABASES' query, eliminate those two databases from appearing in the dropdown box, because I don't want anyone to see them, as they're useless to anybody else. Code:

View Replies !
Selecting Or Adding Values Dynamically To A Drop Down
I have a php page wherein the user can select existing name from a dropdrown or if he doesnt find any, then he can directly type in the select list and it will be added to the database can i get any help in this?

View Replies !
Dynamically Selecting An Option In A Drop Down Menu
I have a database with a couple of fields that only have a certain number of options. I have a page where a user selects 1 record and updates it. When i query the database and retrieve the data in that particular field,

i want that value to be automatically selected in a drop down menu(since there are a finite number of options and this will prevent the user from putting in bad input which would screw up searching). Code:

View Replies !
[PEAR:QuickForm] Dynamically Change A Dropdown Menu According To Another Menu?
I've been using QuickForm for a few months now and I am now given a
new challenge:

I've got a search form with a dozen of dropdown menus, the first
dropdown menu being "Brand". If you select either Brand A, B, C, D...
Z, the second dropdown menu "Model" must be dynamically changed to
model AA, AB, AC, AD..., according to the models manufactured by the
brand selected in the first box.

I've seen that done on quite a few sites, but never found if QuickForm
had a quick & clean way of doing that.

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 !
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 !
Dynamically Populate Drop-down List And Dynamically Include Html File
We have a drop down list on a PHP page, with several product names, and
when people click one item, we will refresh the same page with the
product name as parameter, and in turn we want to include a HTML file
into the content area of the same page.

I know it is recommended to put everything into database, but we want
the web site to be very "portable", so the drop-downlist and the
content should both in text files.

Let's say the drop-down list will be poplulated from the product.txt
file, and there will be a file for each corresponding item in the
drop-down list. From the user point of view, if he wants to add a new
product, he will just need to open the product.txt file, and add a new
line with the product name, "Laptop", then add a new text file named
"laptop" in the same folder which contains the HTML fragment to be
included in the content area.

What is the easiest way to do this?

View Replies !
Database Stores Default Number Everytime, But I Havent Set A Default Number??
Im having some problems with my database. Everytime i store a number which is longer than 10 numbers the script or database puts this number into the database: 2147483647. Its does this everytime no mather how i write the numbers and nomather how long the number is, it just needs to be over 10.

I have set any default value in the database and to be sure i havent i tried deleting the table, but same thing happends again???

View Replies !
GD Default DPI
I'm currently making a website that needs to edit images with adding text,
the problem is, the picture starts at 300 DPI (pixels/inch), but after GD
edits the image, it's set to 72 which i read to be the default value GD
always uses. is there a way to edit that default to a higher number, if not
are there other ways to edit images through php and still keeping the
original DPI.

View Replies !
Default Value
I use mysql 4. The table is

create table a(
first_name varhar NOT NULL default 'defaultname'
)

When I insert into the table
insert into a values('');

The value is NULL not 'defaultname' What am I doing wrong?

View Replies !
Add Default From
I have tried to add a default sender address for my php mail scripts so i dont have to add it on a per script basis. I have access to the php.ini and i have tried two settings.

sendmail_path = "sendmail -t -i webmaster@mydomain.dk"
sendmail_path = "sendmail -t -i -f webmaster@mydomain.dk"

View Replies !
Default Id
I am passing the id parameter through the url, however i want to add a piece of code that permits me to assign a default id value if no value has been passed in the url.

<?php $id=$_GET['id']; ?>

If that is null then $id=25; //

View Replies !
Magic_quotes_gpc On By Default In PHP 4.3.3?
Prior to upgrading to PHP 4.3.3 (Windows), magic_quotes_gpc was turned off in the php.ini file. However, when I upgraded, I told the installer overwrite my previous php.ini files. I didn't have anything special in my previous version of php.ini and I wanted a clean slate.

After I upgraded to 4.3.3, I noticed that my scripts were acting strange, specifically form input. I checked php.ini and found that magic_quotes_gpc was turned on.

I unzipped the installer exe and upon inspecting the php.ini, I found the default php.ini included had magic_quotes_gpc On.

I thought they were going to set magic_quotes_gpc off by default in the later versions.

Anyone know why they did this? Was it a mistake?

View Replies !
What Is Better As A Default Value: NULL Or ''?
I would like to collect some statistical data and then make some reports on it. I'm creating tables for this task and i'm not sure what is better for filling default values: NULL or ''. What is optimal for storage purposes and for further reports creation?

View Replies !
Default Image
How can I write a function in such a way that it would look for a specific image to load. If that image exists on the server it will load it, if not it will load a default image.

View Replies !
Default Variable Value
Does php provide a built in way to use a variable's current value if
that variable is already set but to use a default value otherwise.
That is, a more compact syntax for:

$some_var = isset("$some_var") ? $some_var : "default value";

View Replies !
DEFAULT Switch?
This code works if the IP address is a match, BUT if it is not a match why does this code not use the DEFAULT switch? Code:

View Replies !
Set Column Default
we have a table  sistock with column cameramodel  varchar(30) and try to  set default value to blank with the following:

ALTER TABLE SISTOCK CHANGE COLUMN CAMERAMODEL CAMERAMODEL ENUM ('INSTOCK',
'BACKORDER','SERVICE','OBSOLETE') DEFAULT '';

and we get an error at the mysql prompt;

View Replies !
Default 2147483647
I am doing portal for storing info of visitors.it is working well too.but my prob is with mysql..when i entered infoa bt thier phone numbers ,fax or mobile numbers,soemtimes it is storing 2147483547 instead of given number or default null.can u tell me the reason and solution for it.

View Replies !
Default Charset
When not specifying the charset in a php script, which one is used by default? A php server seems to have a default charset setting (see phpinfo below of my host's server).
Code:

php core
default_charsetno value

Apache Environment
HTTP_ACCEPT_CHARSET ISO-8859-1,utf-8;q=0.7,*;q=0.7

HTTP Headers Information
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7

HTTP Headers Information
Content-Type text/html; charset=iso-8859-1

Though this one seems to have a default charset setting of none, does the http headers information mean that any website or php script accessed with the browser's address bar gets a iso 8859-1 by default anyway?

View Replies !
Set Default Value To The Same Value As Another Field
Basically I have a 'Date Entered' field, which defaults to the timestamp of the date a new record is entered.

I also have a 'Last Updated' field - so when a new record is added, these would be the same - so would like 'Last Updated' to default to 'Date Entered'.

I've tried just entering 'DateAdded' or "DateAdded" as the default in phpMyAdmin, but it doesn't like it.

View Replies !
Default To NULL
table product

products_id, products_name, icon_1, icon_2.

table icon

icons_id, icons_name

When I display a product, I may display some icons (0-2) with that product. So I have the above produc and icon table set up. In the product table, icon_1 and icon_2 will hold the icons_id from table icon, if there is an icon at that position.

icons_id is smallint (Auto Increment key value).

To me it is the same. Both value will never be the icons_id of table icon, which will mean no icon will be shown.

What is your suggestion? In general, in this case, the samillint value will not be used in any calculation, only will be used to refer to another tables auto increment key. When it is EMPTY, should I set it to 0 or should I set it to NULL?

View Replies !
Default Timezone
How do I set the default timezone to Eastern Standard Time? I am displaying the time on one of my pages but it's five hours off of my time so I'm guessing it's england's time.

View Replies !
Set Default Value To Value Of Other Field?
Can I have a table something like this:

COL A
COL B
COL C

where COL B's default value (if none is inserted) is the value entered in COL A?

View Replies !
Set Default Date
i want to set defult date in my date list(eg current date by defult in the list menu of- day,month,year)in php .

View Replies !
Default Select Tag
I have a config file editor page that should read the config file, then automatically select a <option> from a <select> tag. I dont want to have to write an if-else statement for each line in the config file(there are over 200)and I came up with 2 ways to do this and was wondering which would be easier and less cpu intensive.

1) Create a loop for each config option, and check on each step in the loop for what should be 'selected' by default. 2) Make a function to check. EX:

(checkifset prints out selected="selected")

<option other stuff checkifset('config_option','value1'); >Value 1</option>
<option other stuff checkifset('config_option','value2'); >Value 2</option>
<option other stuff checkifset('config_option','value3'); >Value 3</option>

It seems that option 2 would be easier to code(since I already have the html coded out), but it may also be more cpu intensive.

View Replies !
Retrive Default Value
How do I retrive the default value of a column? (I mean the deafult value you can specify when you create your table and that is assigned if you create a record without supplying data for that column).

View Replies !
Php Default Directory
I've installed Apache, PhP 5.1 and MySql. Which is the default directory where I can test my Php scripts?

View Replies !
How Can You Set A Default Checkbox Value?
How can you set a default checkbox value? I'm not sure what toggles it on and off or checked and unchecked. Yes i'm new at all this. But I'm learning well. What i need to go is query my database and if the value isset i want the checkbox to be checked, othewise unchecked.

View Replies !
Default Html
have some input boxes and few buttons. On that page if user hits ENTER key at any time, it will have a specific to be defaulted to invoke [like default=true of Command Button in Visual Basic]. Is same effect possible in HTML?

View Replies !
Default Value In Php Script
I like to my members to be able to include audio and video on their profile page. The EDIT PROFILE page has the following code where the member can enter the audio/video info:

      $audio = "<textarea name='audio' class='text' cols='45' rows='3'>".stripslashes($row["cAudio"])."</textarea>";      
      $video = "<textarea name='video' class='text' cols='45' rows='3'>".stripslashes($row["cVideo"])."</textarea>";

I like to have a default audio and video file which are used if the member do not change the default values above.

View Replies !
Passing A Default Value
I want to have the customer select a link based on a choice of options and go to a customization page where their choice is now the default value in a dropdown menu.

View Replies !
Default Parameter
If possible, how do I use a function to create a default parameter
value? The following gives me an "unexpected '(', expecting ')'"
error, which makes sense.

function DisplayInfo($ID, $startdate=date("Ydm"), $numdays=7) {
...function here...
}

View Replies !
Arrays, Default?
i dont know if you can but i need a custom default value for every element in an array each element isnt created yet, but i need a way of making it so every new element in

$error_array = noformat

but obviously that dosent work, i ve tried it.

View Replies !
Int Default NULL And O?
What is the difference for "int" type if default is NULL or o?

View Replies !
Default Value For Get Variable?
basically i want to set a default value for this variable, which is to be replaced by the new GET variable the user submits, is there anyway to do that?

it seems when i define a variable in the php script, it doesn't get replaced by the values i give via GET simulation (just adding?var=value) to the end of the url.

View Replies !
Default Php Extensions
if phpize needs to be run for default php extensions. by default i mean the extensions that are included in the /ext directory when you unpack the php source code. i've run phpize for a custom extension i'm trying to use (php-ffmpeg), but i'm having a lot of problems right now with configure and make process.


View Replies !
ImageString: How Do I Use A Font That Is Not One Of The Default 5?
I am playing with imagegd for generating images, and was wondering if there is a way I could use a font that is not one of the default 5? I remember reading somewhere about a TT font library for imagegd, but don't remember the specifics. If someone could point me in the right direction I would appreciate it.

View Replies !
Problem On Default Value : : MySQL
Problem on default value : : MySQL

I am facing problem in this line

`datetime` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,

when I tried to crate a new table in MySQL(version 3.23.47-nt)

View Replies !
Default Option On Select Box
I need to make a field in a admin form to be a drop down select box. I have the field right now as: PHP Code:

View Replies !
Using Default DB, User, Password
How do I use odbc.default_db, odbc.default_user and odbc.default_password defined in php.ini in the mssql_connect() function? I do not want to define these vars globally at the application level for many reasons. Shouldn’t calling the function without any parameters force PHP to look at the INI file for the defaults?

View Replies !
Form With To Submits, Which One To Default To?
Say, I have a form. Both cancel and save (in that order) are submits, then in the code I check which button was pressed. The point is that I want the save button (2nd) to be default, not the cancel. Is there a way (in js?) to "focus" the other button? One other way to be some simple js, which submits the page anyway......

View Replies !
Object Default Value In Constructor
I'm trying to write a class with a constructor that takes a single object
parameter. So far so good, but I can't for the life of me make the parameter
optional. I understand how to do it with a numerical or textual parameter,
but not with an object. I tried null, but it doesn't work.

class A
{
}

class B
{
function B($a = ???)
{
if (!isset($a)) $a = new A;
}
}

View Replies !
Default Selection From Query
I'm having difficulty trying to have a DEFAULT selected record from a query in my dropdown box (code below). I have about 20 records in a 'facility' table, which listed names of our company's locations. I want to default select one of those records "exton" to be selected in my dropdown box. Code:

View Replies !

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