Forums
This topic is locked
Displaying value in update form of select types
Posted 26 Jan 2005 16:11:21
1
has voted
26 Jan 2005 16:11:21 Matthew Hartwell posted:
Hello All,Im in the throws of tustling with a new site, my first real site, and i thought i should really start getting some tips from the knowledgable people at this site.
Enough grovel anywayz...here is the problem.
I was working with the video tutorial over at macromedia.com
www.macromedia.com/devnet/mx/dreamweaver/articles/php_videos.html
and ive set up an update form, but the problem is two of the fields in my database get there data from select types within a form, a dropdown list with a number of choices displayed.
The tuturial only shows simple text fields. How do i get those choices highlighted when my update form is displayed. Currently it reverts back to having no choices highlighted. So i want
Option A
<b>Option B</b>
Option C
and now it does
Option A
Option B
Option C
Does any of that make sense? hehe
Im using PHP, MySQL and DWMX.
Replies
Replied 26 Jan 2005 18:24:18
26 Jan 2005 18:24:18 Simon Martin replied:
You'll need to make recordsets to populate the drop downs. Then the bottom option in the dialogue allows you to select value equal to, and gives a dynamic lightening bolt - click on that and select the value from your main recordset.
What this does is to use the options from the simple recordset (select * from table) to populate the dropdown itself and you are then setting the SELECTED value = to the value that's stored in the record you want to update.
Live the life you love
Love the life you live
Simon
What this does is to use the options from the simple recordset (select * from table) to populate the dropdown itself and you are then setting the SELECTED value = to the value that's stored in the record you want to update.
Live the life you love
Love the life you live
Simon
Replied 26 Jan 2005 22:59:05
26 Jan 2005 22:59:05 Matthew Hartwell replied:
That sort of works. It works on one field i have which is a "multiple select type" in the form, highlighting its current value, but then when i update the value. It puts an empty space into the database, like no new option was selected.
So it goes from
<b>Category</b>
Occasional > Birthday
to
<b>Category/</b>
"emptyspacehere"
Also it doesnt seem to work for "select types" in a dropdown
I probably need another recordset im using 2 atm.
One is rs_updategifts(which has
SELECT *
FROM gifts
WHERE ID = colname
and the other is rs_giftcats
(which has SELECT categories
FROM giftcategories
ORDER BY categories ASC)
So i got at the "multiple select form type box"
Options from recordset..........rs_giftcats
Values..................................categories
Labels..................................categories
Select value equal too...........<?php $row_rs_updategifts['category'] ?>
Im almost there i think
So it goes from
<b>Category</b>
Occasional > Birthday
to
<b>Category/</b>
"emptyspacehere"
Also it doesnt seem to work for "select types" in a dropdown
I probably need another recordset im using 2 atm.
One is rs_updategifts(which has
SELECT *
FROM gifts
WHERE ID = colname
and the other is rs_giftcats
(which has SELECT categories
FROM giftcategories
ORDER BY categories ASC)
So i got at the "multiple select form type box"
Options from recordset..........rs_giftcats
Values..................................categories
Labels..................................categories
Select value equal too...........<?php $row_rs_updategifts['category'] ?>
Im almost there i think
Replied 27 Jan 2005 22:52:23
27 Jan 2005 22:52:23 Simon Martin replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>rs_giftcats
(which has SELECT categories
FROM giftcategories
ORDER BY categories ASC) <hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
This looks like the recordset used to populate the drop down menu yeah? <BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>Options from recordset..........rs_giftcats
Values..................................categories
Labels..................................categories
Select value equal too...........< ?php $row_rs_updategifts['category'] ?> <hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
Values should be set to the Primary Key for giftcategories (catID?) This is what will get stored in the database, the Labels are just pretty stuff for us humans that make more sense than the (autonumbered) PK's
In the create recordset dialogue you should be able to test the recordset - if you do this for rs_updategifts it <i>should</i> return the PK for the category selected, and from your original post it sounds like it is... but I just wanted to check.
Next thing to check is that the value you are selecting in the update form is what you are expecting. If you can create a simple page that simply displays the values being submitted and change the form action so it points at your new page then you should be able to check
Let me know how that goes, if you're getting the value you expect on your debugging page then there's no good reason for the update not to work.
HTH
Simon
(which has SELECT categories
FROM giftcategories
ORDER BY categories ASC) <hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
This looks like the recordset used to populate the drop down menu yeah? <BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>Options from recordset..........rs_giftcats
Values..................................categories
Labels..................................categories
Select value equal too...........< ?php $row_rs_updategifts['category'] ?> <hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
Values should be set to the Primary Key for giftcategories (catID?) This is what will get stored in the database, the Labels are just pretty stuff for us humans that make more sense than the (autonumbered) PK's
In the create recordset dialogue you should be able to test the recordset - if you do this for rs_updategifts it <i>should</i> return the PK for the category selected, and from your original post it sounds like it is... but I just wanted to check.
Next thing to check is that the value you are selecting in the update form is what you are expecting. If you can create a simple page that simply displays the values being submitted and change the form action so it points at your new page then you should be able to check
Let me know how that goes, if you're getting the value you expect on your debugging page then there's no good reason for the update not to work.
HTH
Simon
Replied 30 Jan 2005 11:49:18
30 Jan 2005 11:49:18 Matthew Hartwell replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>rs_giftcats
(which has SELECT categories
FROM giftcategories
ORDER BY categories ASC) <hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
This looks like the recordset used to populate the drop down menu yeah? <BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>Options from recordset..........rs_giftcats
Values..................................categories
Labels..................................categories
Select value equal too...........< ?php $row_rs_updategifts['category'] ?> <hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
Values should be set to the Primary Key for giftcategories (catID?) This is what will get stored in the database, the Labels are just pretty stuff for us humans that make more sense than the (autonumbered) PK's
In the create recordset dialogue you should be able to test the recordset - if you do this for rs_updategifts it <i>should</i> return the PK for the category selected, and from your original post it sounds like it is... but I just wanted to check.
Next thing to check is that the value you are selecting in the update form is what you are expecting. If you can create a simple page that simply displays the values being submitted and change the form action so it points at your new page then you should be able to check
Let me know how that goes, if you're getting the value you expect on your debugging page then there's no good reason for the update not to work.
HTH
Simon
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
Thanks Simon, i got it all too work with just a minor change, i had the recordsets the wrong way around <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle> It all works well now
Thx again for your expertise.
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>rs_giftcats
(which has SELECT categories
FROM giftcategories
ORDER BY categories ASC) <hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
This looks like the recordset used to populate the drop down menu yeah? <BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>Options from recordset..........rs_giftcats
Values..................................categories
Labels..................................categories
Select value equal too...........< ?php $row_rs_updategifts['category'] ?> <hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
Values should be set to the Primary Key for giftcategories (catID?) This is what will get stored in the database, the Labels are just pretty stuff for us humans that make more sense than the (autonumbered) PK's
In the create recordset dialogue you should be able to test the recordset - if you do this for rs_updategifts it <i>should</i> return the PK for the category selected, and from your original post it sounds like it is... but I just wanted to check.
Next thing to check is that the value you are selecting in the update form is what you are expecting. If you can create a simple page that simply displays the values being submitted and change the form action so it points at your new page then you should be able to check
Let me know how that goes, if you're getting the value you expect on your debugging page then there's no good reason for the update not to work.
HTH
Simon
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
Thanks Simon, i got it all too work with just a minor change, i had the recordsets the wrong way around <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle> It all works well now
Thx again for your expertise.