ID fields in forms

All WYSIWYG Web Builder support issues that are not covered in the forums below.
Forum rules
PLEASE READ THE FORUM RULES BEFORE YOU POST:
viewtopic.php?f=12&t=1901

MUST READ:
http://www.wysiwygwebbuilder.com/getting_started.html
WYSIWYG Web Builder FAQ
trevorm
 
 
Posts: 47
Joined: Sat Mar 14, 2020 3:43 pm

ID fields in forms

Post by trevorm » Tue Apr 28, 2020 2:28 pm

Hi

I am trying to create a form to add data to an existing Database table. The id field in the existing table is an auto incrementing primary key field. How do set this up in the WYSIWYG Web builder form to ensure that each new record has a new (incremented by 1) value?

Thanks

User avatar
Pablo
 
Posts: 20479
Joined: Tue Mar 28, 2006 12:00 pm
Location: Europe
Contact:

Re: ID fields in forms

Post by Pablo » Tue Apr 28, 2020 2:36 pm

If you set the database field to 'auto increment' then the database will take care of this.

trevorm
 
 
Posts: 47
Joined: Sat Mar 14, 2020 3:43 pm

Re: ID fields in forms

Post by trevorm » Tue Apr 28, 2020 2:38 pm

Further to my inquiry, I am getting the following error

"Failed to insert data into table!
Unknown column 'DATESTAMP' in 'field list'"

displayed when trying to submit the form data to the database.

I do not see a way to ensure the form fields save to the correct DB table fields - the form is not adding to all the fields in the table record.

User avatar
Pablo
 
Posts: 20479
Joined: Tue Mar 28, 2006 12:00 pm
Location: Europe
Contact:

Re: ID fields in forms

Post by Pablo » Tue Apr 28, 2020 3:02 pm

If you use the built-in form script then the table needs a datestamp field.
The names of the form input fields determine the names of the table fields.

If you need different behavior then you will need to implement your own script.

trevorm
 
 
Posts: 47
Joined: Sat Mar 14, 2020 3:43 pm

Re: ID fields in forms

Post by trevorm » Tue Apr 28, 2020 3:12 pm

Hi

Thanks for for your reply Pablo.
What is a datestamp field? or is that just a field with that name to receive data from your built-in script?

User avatar
Pablo
 
Posts: 20479
Joined: Tue Mar 28, 2006 12:00 pm
Location: Europe
Contact:

Re: ID fields in forms

Post by Pablo » Tue Apr 28, 2020 3:49 pm

The datestamp field stores the date of the form submission.
If you look at the generated PHP code then you can see what the table structure looks like.

trevorm
 
 
Posts: 47
Joined: Sat Mar 14, 2020 3:43 pm

Re: ID fields in forms

Post by trevorm » Tue Apr 28, 2020 4:45 pm

Thank you

trevorm
 
 
Posts: 47
Joined: Sat Mar 14, 2020 3:43 pm

Re: ID fields in forms

Post by trevorm » Wed Apr 29, 2020 11:41 am

OK Pablo,

Not being an experienced coder does create some issue for me, some of which you have already helped me with and for that I am grateful.

I am proceeding well with building my web site with WYSIWYG WB and I acknowledge my failure to fully read some of the instructions provided as you pointed out, however comprehensive (or not to a non coder) they may be. But, as I said, not being an experienced coder does have it problems with some elements of the WYZIWYG WB tool.

To return to my query:

As you recommended, I have had a look through the applicable page code, both php and html.

I can see reference in the php code to the "Create Database" and "Create Table" where the Date Stamp, Time and IP fields are referred to but none of my other fields are listed. I can also confirm that via my Service Providers Control Panel, I can see that my database has these fields present in addition to the fields I incorporated when I set up the DB previously for use on an earlier web site.

I can also see in the HTML body section where the inputs and their associated labels are set out. However, I cannot see a comprehensive structure of the table anywhere in the code. That is not to say it is not there, only that I cannot find it.

I am getting the "Failed to insert data into table! Unknown column 'DATESTAMP' in 'field list'" error message even though the DATESTAMP field (and the others) are present in the table.

As I have said several times, I am grateful for your help but I would appreciate a little more "lower level" guidance with this and other issues bearing in mind my coding level and the pretext on which WYSIWYG WB is sold.

I do believe this tool is exceptional but here are some aspects where guidance notes are a slanted towards experienced coders.

I would just like to say I can see where WYSIWYG WB will speed up the UI development for experienced coders. However, I would have thought it unlikely that experienced coders would need this tool to develop a complete web site. That said, I am sure it is obvious to you when reviewing my questions, that I am not an experienced coder hence why I am using this impressive tool to build a web site for my daughter's company. This product is sold with the fore-runner that you do not need to know any code and hence why it is appealing to me. Therefore I do need straightforward guidance on this matter. Thanks.

User avatar
Pablo
 
Posts: 20479
Joined: Tue Mar 28, 2006 12:00 pm
Location: Europe
Contact:

Re: ID fields in forms

Post by Pablo » Wed Apr 29, 2020 12:20 pm

The error is generated by the server.
So, either your settings are not correct or there is something wrong on the server side.
I suspect that the configured table is not correct.

before you begin, make sure the specified table does not exists. Then you can be sure the correct table structure will be generated by the script.
Else you will have to update the structure in the table yourself. This requires some MySQL knowledge.

trevorm
 
 
Posts: 47
Joined: Sat Mar 14, 2020 3:43 pm

Re: ID fields in forms

Post by trevorm » Wed Apr 29, 2020 12:39 pm

Hi Pablo,
Unfortunately the table does exist and has data in it, as it is a table that has been and still is in use by another web site which is to be replaced by this new site.

Your MySQL CRUD extension works fine and I can edit and add records with no problem with the CRUD. However, I don’t want users to have the hat much access to the database for obvious reasons hence that is by I am using a form.

User avatar
Pablo
 
Posts: 20479
Joined: Tue Mar 28, 2006 12:00 pm
Location: Europe
Contact:

Re: ID fields in forms

Post by Pablo » Wed Apr 29, 2020 1:03 pm

For the form script to work, the data structure must be correct. It must match the fields in the form.
The built-in script cannot update the structure of existing tables because this could affect the data.
So, either create a new table or update the structure of the table manually.

MGD4me
 
 
Posts: 161
Joined: Tue May 02, 2017 11:56 pm
Location: Canada

Re: ID fields in forms

Post by MGD4me » Wed Apr 29, 2020 4:20 pm

the table does exist and has data in it, as it is a table that has been and still is in use by another web site
If you you are using an existing database and table, then the form on the new website must use the same identical fields and structure. Can you confirm the new structure matches exactly?

trevorm
 
 
Posts: 47
Joined: Sat Mar 14, 2020 3:43 pm

Re: ID fields in forms

Post by trevorm » Wed Apr 29, 2020 4:49 pm

Hi Pablo,

The good news is that I have created a new (different) table by setting the table name jn the form as one that does not exist in the database. to test it and that works. I let the system create the table. Therefore as you say is a structure issue.

I had missed some fields off the form intentionally because I didn't need them. If I recall correctly, on your MySQL CRUD Extension, I could list the fields and select which ones I wanted to display on the web site - i.e. I did not have to list all the fields on the actual form. I assumed that as there is no such facility on this form, I could just list the fields I want to use - alas not. This is not consistent with the CRUD which I believe you also designed?

As I said, on the original table I opened this discussion on, the code produced to create the page does not, as far as I can see list all the fields in the structure. It only lists the Date Stamp, Time and IP fields. However, I know I have not included all the fields in the form for the reason I say above. Therefore the structure of the form is not the same as the table.

It would be much better if there was a consistent approach to forms across WYSIWYG WB with respect to how they are set up in relation to the database table.

I have no idea how to alter the structure of the existing table (which as data in it), which I would prefer to use.

trevorm
 
 
Posts: 47
Joined: Sat Mar 14, 2020 3:43 pm

Re: ID fields in forms

Post by trevorm » Wed Apr 29, 2020 4:51 pm

I forgot to say the fields I don't want to use in the existing table do NOT have any data in them

User avatar
Pablo
 
Posts: 20479
Joined: Tue Mar 28, 2006 12:00 pm
Location: Europe
Contact:

Re: ID fields in forms

Post by Pablo » Wed Apr 29, 2020 5:11 pm

The built-in script is a generic solution. The script is generated based on the input fields of the form.
If you need different functionality then you will need to implement a customer script.

Post Reply