Hi,
I have a php form that encodes the responses to various <Select> field
drop down menus as numbers (e.g. 0 to 50), and then posts the data to
a MySQL table. I am trying to implement a form to allow editing of the
data already in the table. I can read the data out of the database
without trouble, however I am having trouble figuring out a way to have
the appropriate option in the <Select> fields chosen to reflect the
data already in the database. Does anyone have any suggestions on how I
can accomplish this?
Best wishes,
George Hadley gh********@yaho o.com 1 8826 gh********@yaho o.com wrote:
[snip] I am having trouble figuring out a way to have the appropriate option in the <Select> fields chosen to reflect the data already in the database. Does anyone have any suggestions on how I can accomplish this?
Sure.
$data = mysql_fetch_arr ay(mysql_query( 'SELECT fieldname FROM table WHERE
id='.$theId));
echo '
<select name="mylist">
<option value="option1" '; if ($data['fieldname'] == 'option1') { echo '
selected="selec ted"'; } echo '>Option 1</option>
<option value="option2" '; if ($data['fieldname'] == 'option2') { echo '
selected="selec ted"'; } echo '>Option 2</option>
';
....etc...
echo '</select>';
This is how I do these things atleast. The point is to check if the
option is the one in the db, and if it is, add selected="selec ted" (or
just selected if you're not using xhtml).
Roy W. Andersen
--
ra at broadpark dot no / http://roy.skyggenesdal.org/
"Hey! What kind of party is this? There's no booze
and only one hooker!" - Bender, Futurama This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Astra |
last post by:
Hi Guys
Can anybody advise me on how to check for a 'no later than today's date'
value from 3 <SELECT> fields.
I have 3 <SELECT> fields, which are one for the day, one for the month and
one for the year. All are numeric, ie the day format is 1 not 01, the month
format is 11 not Nov, the year format is 2004.
I have done a bit of ASP to make these <SELECT> fields auto-SELECTED to
|
by: joiv |
last post by:
I'm making a <select></select> with lots of <option></option>. It
contains all possible options. Because of the length of the list, I
also have an <input type="text">.
This is what I wish to do:
onKeyDown I want all options that don't contain (or begin with, it
doesn't matter which one) the typed letters to be removed from the
<select>.
My problem is that I don't know of any code to find words and identify
|
by: Brian Foley |
last post by:
Hello,
I am used to using the label tag with check boxes and radio buttons in
html forms. This allows me to click on the text of the label to
activate/deactivate the check box / button, rather than having to
click on the (possibly small) box or button.
I recently tried to assign a label to a select "drop down list", but
found that when I clicked on the label text to bring it into focus,
the select box was reset to the first entry. ...
|
by: Chris Fink |
last post by:
Does anyone know it is possible to include a small image(.gif .jpeg)
within a <SELECT><option> so that the user would see the option text as
well as a little image(icon) in the option? I know this is not an ASP.NET
related question, but I know this group is knowledgeable and quick with
responses.
Thanks
|
by: frey |
last post by:
i tried to create a dropdown menu and use the option as a control to
change content inside another text area
the code is like this:
<select name="xxxx"><option onclick="changeunitprice(29.87)"
value="1744"/>
the function changeunitprice() is called when an option is selected
| |
by: luftikus143 |
last post by:
Hi there,
I have a nasty little problem, as so often, only with IE. Here is an screenshot to better illustrate the problem. http://geodata.grid.unep.ch/screenshot13.png
The map is clickable (to enable zoom in and other functions). But in this case, I would like to select a value from the drop-down list, which displays as a "drop-up" list because of not having enough space downwards.
Now, when I click to select a year, IE interprets this...
|
by: Sonnich |
last post by:
Can anyone give me a quick hint for this?
Say, I have: <SELECT NAME="opt3" SIZE="15" multiple>
Then I'd like to list the items selected...
echo $_POST;
but this gives only the first one
how do I get the rest?
|
by: Man-wai Chang |
last post by:
--
iTech Consulting Co., Ltd.
Expert of ePOS solutions
Website: http://www.itech.com.hk (IE only)
Tel: (852)2325 3883 Fax: (852)2325 8288
|
by: Shrek |
last post by:
I have a drop down on a web page and want to change the cursor from default to pointer, so my style definition has
style ="cursor: pointer;"
the drop down though fails to change from the default curor. I've tryed applying the style to the <select> tag and to the <option> tags to no avail.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |