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

Not sure if this is a DA or DFP question...

Thread began 7/12/2010 5:03 pm by jeffmg279672 | Last modified 7/20/2010 5:25 pm by jeffmg279672 | 1851 views | 14 replies |

jeffmg279672

Not sure if this is a DA or DFP question...

I've attached a zipped page which on the live site needs to do two things - pull some data from one table, and write some data to two others. The 3 drop down menus are to be dynamically populated from one table (practicelist) while the comments field is to be written to another table (reviews) at the same time as the reviewer's name, pet's name, contact name, address, phone and email fields need to be written to the third table (reviewers). The idea being that on another page, the review information will be dynamically added to the results page for each practice.
So far I've set up a recordset for each of the three tables, but have no idea how to move on from this. Each time I've added a recordset, it attaches another link to the connection script, so I've removed two of these.
I'm assuming that I can achieve what I've outlined above using DA, but would appreciate some very detailed guidance (in real newbie terms) explaining how to do this, please.

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

Eric Mittman

You are on the correct start. If you have dynamic information to display on your page you will need to make use of the recordsets to show this info. Once you have crafted the recordsets you can then drag and drop the bindings onto the page where you would like to see the info for that record.

As for recording info in your this will be done with either updates or inserts into your tables. You can use the DataAssist Insert and Update server behaviors for this. It is very straight forward, when you apply either an insert or an update to the page it will guide you through the setup. You will select the table and fill in various values along the way. You will get to a page that shows the columns for that particular table, on this page you set the values that you would like to insert or update the table with. If the value is dynamic like the comments input you would use the lightning bolt icon to select the form element for comments.

If you have not done so already you should check out the DataAssist Support page by visiting the support section of our site. The getting started guide should cover this info and more.

support/

Sign in to reply to this post

jeffmg279672

Thanks for the response to my query. I have put a page together (zipped & attached) and hope you can clarify a couple of issues for me.
I've put a form on the page which hopefully uploads some fields to the reviews table and also to the reviewers table. I did this by running the DA wizard to create an insert page to insert records into the reviews table, then added additional form fields and a DA insert record behavior to insert these into the reviewers table. To do this I have a separate recordset for each table.
I should stress that I haven't tested this yet so I don't know whether that part is right or not. My problem is this - I want the reviewers to be able to select from 3 drop down menus at the top of the form the location, the type and the name of the vet practice respectively. So, I've added a drop down for each and bound them using a third recordset, then altered the code in the recordset to select DISTINCT for each. However, that's not happening - when I test the page locally using MAMP, I'm getting a page which loads slowly, with the 3 drop-down menus building first, then the rest of the page. And when it's fully loaded, I've got multiple instances of locations rather than one of each, which isn't what I wanted.
So... the question is, how do I alter these 3 menus so that they do what I want (which is for the reviewer to pull down the location first, then the type, then the name of the practice, then fill out the form to upload a review that's specific to that vet in that location)? Thanks in advance for your help.

Attached Files
add_review.php 2.zip
Sign in to reply to this post

Eric Mittman

The problem is that you are using the same recordset for all three select lists. You should have a single recordset for each of these three select lists. Each recodset should only select the column and id from the table for the select list you are working with. It looks as though you are using the distinct keyword correctly, for more info on it have a look here at the w3schools site:

sql_distinct.asp

I think if you had these three select lists working with three unique recordsets you would get the result you are looking for.

Sign in to reply to this post

jeffmg279672

OK, making progress here - I now have three recordsets so that location, type and name are now loading quicker and are showing only one instance of each value.
However, what's more concerning is that the insert doesn't seem to be working - I tested it and it was inserting "reviewersname" rather than the value on the form, so I've made some adjustments and got that sorted, but only some data was being inserted into the database, so I looked through the insert record server behaviors again and made a couple of changes. Now I'm getting this error when testing locally:
Duplicate entry '0' for key 2

Looking at the two insert record server behaviors I think it's something to do with the insert of the comments and the reviewrating - that clearly isn't working properly. I've attached the latest version of this page (zipped) and hope you can clarify what's going on here. Thanks in advance once again.

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

Eric Mittman

Usually when you see this type of error it is because you are trying to insert a value for a key column that already exists. Key columns are meant to be unique, so it will not allow you to insert a record that duplicates a key column value.

I looked at your inserts and it does not seem that you are inserting the id for the table which is the most common cause of this issue. Based on what I see on your page it would seem that you have set one of the columns you are inserting into as a key column for the table, thus not allowing any duplicate entries for that field. If you can post back with an export of the db structure in .sql format I can take a look and compare it to the inserts that you have on the page to determine if this is the problem.

Sign in to reply to this post

jeffmg279672

db as a sql file attached.

Attached Files
goodvetguide.sql.zip
Sign in to reply to this post

jeffmg279672

Made some small changes, but basic question remains...

Hi Eric - I realised that what I should be doing for this add review page was to start off with a page with a dynamic drop-down (review_add.php) so that the user selects the location first, which then triggers the options for the practicenames, and once they've got the one they want to review from the child drop-down, they hit Submit and then arrive on the page where they can put in their review info (add_review.php).
So... I had to split the database down to add a new table (locations) and I've attached this along with the two pages that now form this select/add review part of the site as a zip file.
Please ignore the earlier version of the db sent across, this is now the one I'm working with.
I've got the drop downs working ok, and assume that I need somehow to pass the value of the practicename from the first page to the second somehow, but I'm now how to do this - I've added a text field on the second page with practicename bound to it from the recordset but I presume that something more complicated needs to happen with it to make the correct value be passed from the first page? If it's a javascript solution, I'd appreciate having this spelled out in words of one syllable as I'm even more of a newbie with js than I am with mysql/php.
I tried testing these two pages locally and although the first page redirects to the second, when this comes onscreen it still has this "Duplicate entry '0' for key 2" error message and nothing else displays.
It's 4.30pm Friday afternoon here in England, I'll check back later and hope you'll be able to help me move this on somewhat, I'm supposed to be showing this to the client on Monday... thanks in advance.

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

Eric Mittman

I'm not fully understanding what the problem is, when or where it is occurring. I thought that the duplicate entry error was occurring when you were inserting the record. It seems that you are saying that you see it at the top of the page when you try to go from page one to page two.

Do you have a link where this can be seen? If not I would like to open a ticket for you on this so we can get the details cleared up.

In general what you have described here should be just fine. You are essentially just getting to a particular id value and passing this along to the second page. The next page would need to take this value and filter a recordset on it. You can then use the values from that recordset anywhere on the page you would like to see info for that record. If you are inserting into a table you must ensure that you are not inserting into any of the key columns unless you know you are inserting a unique value.

My feeling is that this issue is more simple that it seems, but that we are on different pages about what the problem is and when it is occurring. Please post back with the details about this and include a link where we can see this. If this is not something you can post let me know and I will get a ticket opened for you on this issue.

Sign in to reply to this post

jeffmg279672

You're right in that the error was originally occurring when inserting the record, but since I've changed the pages and the database slightly, it's now occurring when going from one page to the next.
At the moment I'm testing this locally so I don't have a link where it can be seen, unfortunately. I've deleted the insert record actions from the second page, to see if that was what was causing the problem, and this time the page loads, but I get a different error message -

Notice: Undefined variable: row_rsChild in /Applications/MAMP/htdocs/goodvetguide/add_review.php on line 12.

I've re-attached the modified second page (with insert records and other recordsets deleted).
Hope this helps.

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