close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Update page to modify database

Thread began 1/08/2017 5:40 pm by GaryMorris | Last modified 2/07/2017 2:54 pm by Ray Borduin | 111 views | 10 replies |

GaryMorris

Update page to modify database

Hi. Happy New Year..
You helped me a while back with this page to modify the database. That worked perfectly. I had to add a checkbox array to the page. I was able to figure it out for the initial add page and that works great. What I cant figure out is how to make it work with the update page. I see what you did on the single checkboxes to have them show if they were checked and update correctly but I have not the faintest idea how to make it work for an ARRAY. I would appreciate any guidance you could provide. The page is attached.

Sign in to reply to this post

Ray BorduinWebAssist

You would probably want to:

1) create a recordset to return the previously selected infractions
2) loop through the recordset to get the infractions into an array
3) use the in_array() function to check the previously selected boxes

Then on update you will want to delete all of the previously selected incident records and use the same logic from the insert page to re-insert the ones checked on the update form.

Sign in to reply to this post

GaryMorris

Ok. I got the recordset to read the 'infractions' field. I think I am confusing myself. The 'infractions' field in one recordset reads as follows:

B4NR,4571,AAUP,ADDY,BATT,290R.

So if I read that field how do I get it to pull each one (comma seperated) into an the array to make this happen. Do I use 'explode()?
I really want to figure this out myself but....
Thanks.
Gary

Sign in to reply to this post

Ray BorduinWebAssist

Yes.

$InfractionsArray = explode(",",$RecordsetName->getColumnVal("InfractionsColumn"));

Sign in to reply to this post

GaryMorris

Ok.. I get that part now. I entered it as:

$InfractionsArray = explode(",",$Recordset3->getColumnVal("infractions"));

var_dump($InfractionsArray); puts this on the top of the page.
array(6) { [0]=> string(4) "B4NR" [1]=> string(4) "4571" [2]=> string(4) "AAUP" [3]=> string(4) "ADDY" [4]=> string(4) "BATT" [5]=> string(4) "290R" }
That part now makes sense.

Being I am using the individual check boxes for each infraction, does each checkbox <input statement need to loop through the InfractionsArray to see if it is selected.

Reference the out of state checkbox (which you helped me with a few months ago). I know this (below) is not an array but how do I make it check to see if it is being used or not.

<input <?php if (!(strcmp(($Recordset1->getColumnVal("outofstate")),1))) {echo "checked=\"checked\"";} ?> type="checkbox" name="outofstate" id="outofstate" value="1" class="formCheckboxField_Standard" tabindex="13" title="Please enter a value" />

Thanks again for all the help.
Gary.

Sign in to reply to this post

Ray BorduinWebAssist

php:
<input <?php if (in_array("1",$InfractionsArray)) {echo "checked=\"checked\"";} ?> type="checkbox" name="outofstate" id="outofstate" value="1" class="formCheckboxField_Standard" tabindex="13" title="Please select an infraction" />
Sign in to reply to this post

GaryMorris

Thanks Ray,
That got it working.
I used <input <?php if (in_array("B4NR",$InfractionsArray)) {echo "checked=\"checked\"";} ?> type="checkbox" name="B4NR" id="B4NR" value="1" class="formCheckboxField_Standard" title="Please select an infraction" />

You had it "1",$InfractionsArray)) I assumed that would work if I was just using numbered items. I put in the checkbox name instead and it works perfectly.. Now to get it to update.. Thanks again.

Sign in to reply to this post

GaryMorris

I've got it working in the way it checks all the boxes that are selected for the record. Set up the update record and had it blank the entry. Problem is when updated it changes the entry in the field in the db to on,on. At one time it was 1,1. Not sure what changed. Plus obviously not adding the new entries. Attaching the updated page.

Also on this same page, near the bottom, it lists the <script src="../webassist/forms/wa_servervalidation.js" type="text/javascript"></script>
10 plus times. Question is, can I delete all that are duplicates?
Thanks.
Gary.

Sign in to reply to this post

Ray BorduinWebAssist

You can delete duplicate script references.

The issue with the checkboxes is that they are missing the value attribute. Each checkbox should have a value set that matches what you want inserted into the database. (Also the "for" attribute of the label should match the id of the checkbox although that isn't related to your problem)

So the first one should be:

php:
<label for="B4NR">

                                 <input value="B4NR" id="B4NR" <?php if (in_array("B4NR",$InfractionsArray)) {echo "checked=\"checked\"";} ?> type="checkbox" name="infractions[]" /></label>
Sign in to reply to this post

GaryMorris

Just wanted to thank you for your help. This is working great.

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