I'm looking for some code-examples, any help appreciated;
So far I have only created auth and email forms using php and mysql in my web-life, and did that working from existing examples, which went easy for me because I understand the basics of many different programming languages and their syntaxes. However, now I need to create some fairly complex webforms for some people, and I bump into a lot of issues that are not so easy to find examples for.
The intention is to make certain parts of a large MySQL database easier to add new records to, and/or change them, and for that I have to create some webforms. One important thing is that they want me to put many form actions on just one page, with one submit button (that is how I got the idea to use a conditional wForm script). For now let's assume all related fields are of the varchar(128) type to keep it simple.
(Restricting access is not an issue (I have that down) because it works outside of the form using a cms-type thing, giving access for the form only to those that are allowed to add or change records etc.)
Let me describe some of the involved structure and actions I need for one of the forms, because when I get one done (with help of some example code from you perhaps), it's easy for me to understand and create more out of it;
In an existing (and already populated) TABLE_X the user needs to add a new record to field_x but I need to check if needed field_x already exists, if it does, it should be selected from the database and query and echo a lot of contents under that form entry, if it does not exist it should be (as filled in a textbox by the user) added to MySQL and then continue further down the form. Aside from this, whatever the user has picked (picking an existing one or filling in something new) ALSO needs to go into field_y which resides in TABLE_Y and in field_z residing in TABLE_Z (but this happens hidden from the user).
In the same form-page I then need to have a dropdown box showing the records in field_a from TABLE_A but show only those records in the dropdown for which field_b (from TABLE_A) has values (record) xx and yy. The user selected item from field_a should be added as field_h which resides under TABLE_H
Then I have a couple more that are similar to this on the same page. Basically I need a complete example (including where I need to put the include for the connection to the database) so I understand how to create the user selects existing or adds new record issue in a webform, plus I'm at a total loss on doing the cross table writing and reading in one form.
If anyone could provide a simple example using the exact table and field names mentioned in my puzzle above, I'd be on my way and very thankful!
Hello, perhaps someone else will be able to give you a more in depth response, but it seems to me what you are describing is more a need for an active records framework to make your php dealings with databases easier.
I would recommend cakePHP. This tutorial will show you some of the power of this system to make your life easier: http://book.cakephp.org/view/326/the-cake-blog-tutorial
Let me know if you need more information after reading that. And of course your views created with cakephp should use wForms for their field validations and such.
Unfortunately, this has nothing to do with a blog. It's for a scientific results collective database. Also, I have no control over the server's software. I have only access to use php 4.4.4, with mySQL 4.1 and the one big database.
Oh hey. What kind of science? I'm an MS chemist myself.
If you dont have access to the server, this sort of effort is going to be a challenge. (Where are you running your php scripts from then?) I guess basically what you would want to do is use php/mysql to create arrays and then use those in templated php-html code, but without using some sort of php framework I think you will be in for a lot of work. Have you tried on dedicated php forums to see if anyone has any suggestions?
It's actually climate research data, with lots of dependencies. The budget is quite low for this part of the entire field, so we can't hire a programmer to build this for us, which is why I was asked to do it. (I already maintain their cms-es)
I can use php and mysql just fine, I just can't install server-software with new Apache and php requirements. It seems to me cakephp is way too complex for what I want; I just need some webforms.
And yes, I've already asked in several forums, nobody responded.
Well ultimately I think you are going to have to write your own mini-framework to accomplish this.
It seems that you will need: 1. Functions to get your data into/out of your database. 2. Functions to evaluate the data and get whatever related data needs to be displayed for the chosen data set, get them using 1, then process them into useable arrays. 3. Functions to create your html frontend using the created arrays to populate the dropdown boxes, and to post the data back into 1.
You will also need to decide if you are going to build it ajax or traditional. You might try drawing a mockup of the frontend and seeing just how many interconnect elements you will need.