close ad
WARNING: Do Not Install the DREAMWEAVER CC 2017 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Update Multiple Select prefill existing values

Thread began 2/25/2013 2:15 pm by tn228553 | Last modified 9/26/2013 11:13 am by Jason Byrnes | 3967 views | 10 replies |

tn228553

Update Multiple Select prefill existing values

Hello,

I have a multiple select that is currently reading from a Recordset to populate dynamically.

This is working great, however on the update screen I am losing the values for this select because they are not pre-populating from the record? How do I continue to dynamically read in a recordset as options but also pre-fill data on the form so I don't lose it upon update?

<select name="icons[]" multiple id="icons">
<?php
do {
?>
<option value="<?php echo $row_icons['id']?>"<?php if (!(strcmp($row_icons['id'], $row_WADAgbl_qemplisting['icons']))) {echo "selected=\"selected\"";} ?>><?php echo $row_icons['name']?></option>
<?php
} while ($row_icons = mysql_fetch_assoc($icons));
$rows = mysql_num_rows($icons);
if($rows > 0) {
mysql_data_seek($icons, 0);
$row_icons = mysql_fetch_assoc($icons);
}
?>
</select>

Sign in to reply to this post

Jason ByrnesWebAssist

send a copy o the insert and update pages please.

Sign in to reply to this post

tn228553

update/insert

here you go:

Attached Files
gbl_qemplisting_Update.zip
Sign in to reply to this post

Jason ByrnesWebAssist

I'm confused by your pages, I have created a support ticket so we can look into this issue further.

To view and edit your support ticket, please log into your support history:
supporthistory.php

If anyone else is experiencing this same issue, please append to this thread.

Sign in to reply to this post

Heckie

I think I have a similar problem - i need to show all the previously selected options on the admin update page - it works fine when there is only one option, but not if there are multiples (it doesn't show any).

Sign in to reply to this post

Jason ByrnesWebAssist

This is a fundamental flaw in the database design.

you should be using a linking table to create a many to many relationship between the directories and venues table, and using the Mange relational Table server behavior to store the selected venue IDs in the linking table.

same holds true for the styles locations and ages column.

any time you find yourself storing a comma separated list of values in a column, you should really be using a linking table instead

see the Managing relational tables tutorial for details:
http://www.webassist.com/tutorials/Manage-relational-tables

Sign in to reply to this post

Heckie

I have set up linking tables for Category, Locations, Ages, Styles and Venues, and followed the Managing relational tables tutorial that you linked above.

I have set up a 'Manage Relational table' behaviour for each one (5 in total), but none of the values are being stored in the tables, and in fact it removes the previous values.

It seems to work OK when you first visit the page, in that it selects the correct tick boxes.

Attached Files
Directory_update.php
Sign in to reply to this post

Heckie

Found the problem.

There was an extra space inserted in the checkbox value after the dynamic value. Removed those and it now works as expected.

Sign in to reply to this post

Heckie

I replaced 5 columns (Style, Category, Age, Location and Venue) in my table with 5 relational tables - DirStyle, DirCat, DirAge, DirLoc and DirVenue.

I had a search results page on my site that worked fine when I had the items comma separated in the Directory table but I can't get the WA Search to work now that I have removed the 5 columns.

I have written (bodged) some SQL (pasted below) to try and replicate the functionality by joining the tables and re-creating the columns.

However, WA Search will not allow me to use choose these columns, even though they appear when I test my SQL in dreamweaver.

Any ideas?

Sign in to reply to this post

Heckie

Think I got it working like so:

SELECT DirectoryID, Title, Summary, Image, DirCatCategoryID, DirStyleStyleID, DirAgeAgeID, DirLocLocationID FROM Directory INNER JOIN DirCat ON DirCat.DirCatDirectoryID = Directory.DirectoryID INNER JOIN DirStyle ON DirStyle.DirStyleDirectoryID = Directory.DirectoryID INNER JOIN DirAge ON DirAge.DirAgeDirectoryID = Directory.DirectoryID INNER JOIN DirLoc ON DirLoc.DirLocDirectoryID = Directory.DirectoryID WHERE Approved = 'Y' GROUP BY DirectoryID

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...