close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Multiple checkbox update

Thread began 6/02/2010 6:28 am by georgina_barrett_187762 | Last modified 3/07/2011 10:37 am by Jason Byrnes | 8693 views | 30 replies |

georgina_barrett_187762

Multiple checkbox update

I have 5 table in my database. One to store resort information 'resortdetails', one to store the names of amenities 'amenities' and 3 which tie the 2 together 'amenitiesonsite', 'amenitesunit', amenitiesother' . These are identicle in structure and store the resort id and the amenities id.

For example a resort have multiple unit amenities, multiple onsite amenities and multiple other amenities.

I have created an insert page that lists all the amenities from the amenities table as checkboxes and then once an amenity is checked it will get uploaded to one of the databases 'amenitiesonsite', 'amenitesunit', amenitiesother' (there are 3 multiple inserts on the page)

Now I am trying to create the update page. I have created 3 recordsets to pull in all the amenities from the amenities table (1 may have done for all of them but to make it easier for me to understand I have created 3 identicle ones - naming them differently)
Each of these are repeated checkboxes.

I have created 3 other recordsets to pull in the amenities that are stored in the 3 tables 'amenitiesonsite', 'amenitesunit', amenitiesother'. Using the resort ID that is passed from the previous page (S_resortID).
I have tried to dynamically bind the checkboxes so that if a value from the amenities table matches one from the amenitesunit table mark the checkbox as checked.

This works so far as it checks a correct amenity for each of the tables however it only checks one amenity even if there are numerous in the amenitesunit table for that resort. I guess it needs to repeat the recordset somehow - but I don't have a clue where to start.
I have attached the file.

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

Eric Mittman

It looks as though you are not updating the recordsets to go to the next record within your looping. I did not see any MySQL fetch assoc function calls within the looping around the checkboxes so it seems that this is the problem.

Do you have a live page that you can link to? This would help us to see the source and determine what values the checkboxes are getting and the best way to update it. Please post back with this and if you can a copy of your db so that we can do some testing with this.

Sign in to reply to this post

georgina_barrett_187762

Thank you. I have attached a copy of the tables as an sql file. I can't give you access to the live file as it is all password protected.

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

georgina_barrett_187762

That sound like it is the problem as I have a DA repeat region to display all of the amenities checkboxes from the amenities table. I need another loop to see if any of the checkbox values match data in the amenitiesunit table. Would I need to put the values in an array? I am sorry- I really have no idea what I am doing when it comes to hand coding hence purchasing this package. I can tweak code but that is about my limit.

Sign in to reply to this post

Eric Mittman

Thanks for posting back with the db but the information is missing from the sql. If you can post back with the full sql that includes the records from these tables and I will help look into this further with you. I think that you either need to set the looping up differently or there might need to be another recordset and/or repeat region to do this. Please post back with the data so that I can give this a test with your info to see what would need to be done.

Sign in to reply to this post

georgina_barrett_187762

Here you go

Attached Files
exclus_holiday (2).zip
Sign in to reply to this post

Eric Mittman

I was able to get into the code on the page and add in some looping for the unitdisplay recordset that you are comparing to. What I noticed for at least the first column of checkboxes was that there is only a single entry for that ref ID. I was trying to test with others that might have more than one value but could not find any to test for this. I checked on all of the id values that I saw in the amenitiesunit table and it seemed that there was only a single Unit Amenity for each one.

This tells me that there might be a problem with your recordsets that you are using for the display, it seems that it only ever has a single record, at least for the unit amenities. I'm including a copy of the page that I updated for your. You will see around lines 286 I added the loop for the display recordset.

You can replicate this for the other two columns of checkboxes by copying the code and updating the reference to the recordset. Please check this out and do some testing with your data to see if the recordset is not working correctly or if there is only a single match for the ones we are testing with.

Attached Files
amenitiesonsite_Update.php.zip
Sign in to reply to this post

georgina_barrett_187762

Brilliant thanks - I added

if ( mysql_num_rows ( $unitdisplay ) > 0 )
{

Around

mysql_data_seek($unitdisplay, 0);
$row_unitdisplay = mysql_fetch_assoc($unitdisplay);

Because like you said on the amenitiesunit table there aren't always any records, and it was throwing up an error.
mysql_data_seek() [function.mysql-data-seek]: Offset 0 is invalid for MySQL

Once again - thank you.

Sign in to reply to this post

georgina_barrett_187762

The checkboxes work fine now and ones in the database check the correct checkboxes. However I have 2 problems. The first record that gets pulled in on each recordset i-e. the first checkbox that is checked - doesn't display the checkbox, it is hidden. All the others are fine and display checked it just seems to be the first one from the recordset.

Also the multiple updates don't work. I can't get it to add a new amenity or remove one that is currently checked.

I have attached a copy of the page.

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

Eric Mittman

Thanks for posting back with this, I think we should work on these issues one at a time. For the checkbox that is not appearing as checked please describe a little more about what you experience. Please include id numbers in the URL so that I have a reference. Also, if you could provide a screen shot so that I have something to compare to that would also help. When we get this issue worked out we can look at the update server behavior.

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...