Making dynamic forms work with my back-end database - php

I'm looking for some advice. I have been given a paper form with various criteria. I need users to be able to select a type of transport (Bus, Train, Taxi, Tram, Other).
Upon the selection, I need more fields to be produced in a form based on the user's choice. So questions about Bus times would be produced if the user selected bus.
The fields will be generated using PHP and MySQL. I have seen some JQuery solutions but I'm a little confused as to what my approach should be.
Can I use JQuery, PHP and MySQL together or can my problem just be achieved using just PHP and MySQL. Please note, the fields will be stored in my MySQL database already, I just them to be generated after the selection from the dropdown menu has been displayed.
No source code sorry everyone as I'm just asking about the approach I should take. I hope I've provided enough detail!

There is no way to achieve this solution with just PHP & MySQL. You would need to Ajax/JQuery to achieve this. Based on user's selection you need to send the data to server using JQuery Ajax and then server will send back the response that you need to show to the user.
This link should help you.

i think,
actually you can achieve this by only using php and mysql, jquery makes you easier when you play with DOM, with out it you can achive that goal, but need extra work with native javascript.
CMIIW

Related

PHP MySQL and ajax practice projects

What are some good simple projects for practicing PHP and mysql work?? Also implementing Ajax??
I am fairly new to PHP and mysql, and would like to gain more experience, I also enjoy using Ajax and xml
The most simple one is a Signup/Login Form.
While, signing up use JS to validate the form, and ajax call to submit the form data. And while taking a userId as input, you can use ajax call "onchange" to verify it's existence.
Then go for an Quiz App.
Self issuing Online Library.
And, the best one Online Pizza Ordering System.
How about trying to implement things that Facebook does, for example-
Tagging a person as you type their name
A simple chat box. Also take a look at this SO discussion
Some more googling gives you 25 Excellent Ajax Techniques and Examples

How to fetch data from website without API

I want to fetch all current and future courses form this website http://www.scfhs.info/cme_pd/search/index.php for example this queries http://www.scfhs.info/cme_pd/search/do_search.php to my iOS app , unfortunately they don't have an API.
How to get the data?
Check this out https://www.parsehub.com/ this will help you for sure
I've done this for a project, search for html scraping. There are a tools to do it that vary depending on your platform. Here is a start. Unfortunately if the page changes you have problems. In my case the pages would update in an inconsistent manner. It looks like most of the data you want is in option tags; that should make it easy to parse.
I would have made this a comment, but I'm not worthy yet.

Creating a user-specific calendar

I want to create a fairly simple webpage where a user logs in and can manipulate a calendar that I create (perhaps with a HTML table?). I've already created a simple login service with a few HTML and php pages and have basic user info stored in a MAMP server.
Correct me if I'm wrong, but from here I would need to layout a calendar in HTML and maybe have link table cells to an edit page where the user can create a new event. The real question here is what is the best way to go about storing information like this on my server? Using PHP and MAMP like I did with the form data at registration?
I'm still fairly new to databases and working with servers and such, so just looking for a little guidance so I don't waste time learning a completely incorrect approach to this.
MySQL and PHP are definitely the way to go in my opinion. I would look into Javascript and AJAX if I were you also. Using AJAX, you could have a user enter information into the calendar directly and store it in the database without having to leave the page. jQuery is a very nice and simple library for working with Javascript and AJAX and I would very highly recommend it. It greatly simplifies working with Javascript.
As for the calendar itself, using a table seems like the best approach to me.
For storing information in MySQL, I'm seeing a table somewhat like this:
UID|EntryID|Date|Time|Event|etc.
You could store this table separately from your users table and join them easily when making requests. For instance, when a user logs in, you can pull the users UID from the users table you have set up, then pull all entries out of the calendar table with matching UID's and manipulate and display this information with PHP and Javascript.
There may be (and most likely are) better ways to set up your database, but this is kind of just a general concept of how you could get it to work. There are certainly people here with much more experience in MySQL and database design than myself.
Overall it sounds like you have a good idea working for you and have a pretty good idea of what it will take to make it happen. I wish you the best of luck on your project!

PHP + MySQL + Ajax Search or Data Framework

i tried several ajax/js "frameworks" and "data grids" to show some mysql data, but the problem is that i have to many columns (like 50) and some of then need to be links, images and also get the ID from the same query to create those links
the main features that im looking is good search, sort and filter
i dont have the time to make all of this script (and learn more about ajax), i'm not a php/mysql beginner but the problem is the ajax thing. so what im looking for is some script, framework, datagrid or anything that could make what i described, with less code edit as possible
if you can came up with another solution that already comes with ajax, that might be useful too
Maybe you want to try out jqGrid. Besides the jQuery version, they have a new all-PHP version that handles all the programming without AJAX. It might be exactly what you're looking for. It handles large data sets, and has a huge demo site with example code, including the PHP/MySQL back end.

Linked pulldown lists using MySQL, PHP/JavaScript/Ajax/jQuery

I am quite new to web development and have a task to develop a web application that will basically show the user 5-15 pull down lists on one page, where each selection will limit the choices in all other lists. The user should be able to start with any one of the lists (so no set selection order) and when the user have selected something in each list or all parameters are otherwise locked by previous choices the user has to press the GO button and some calculations will take place, presenting a database selection. Basically it is a muliple parameter product selector application.
The relations between the lists are not simple, and could need calculated fields etc, and one list could affect the content of several others. The database behind will be MYSQL, probably a single large table, with perhaps 30 fields and 500-5000 rows. I will be using PHP, JavaScript and perhaps AJAX unless you have a strong reason not to.
I have done some research and found three ways to do this:
Send all data to the browser and handle the filtering etc client side with Javascript.
Send parameters back to the server after each selection and reload the whole form after each selection. Probably a littebit Javascript and most code in PHP.
Use AJAX to change all list content dynamically without reloading the whole form.
Since I am so new to this I have a hard time telling which way to go, what pitfalls there are etc...
I have some conserns:
A. Slow initial loading. Worst for #1?
B. Slow dynamic response. Worst for #2?
C. Complicated programming. Worst for #3?
D. Compatibility issues for different browsers and plattforms. Have no idea of which method is most likely to create problems...better if I use some Framework?
E. Could I even try to make something at least part-working for people with javascript turned off? (like selecting each list on a new page and having to press GO button each time)? (I think I can tell my users they must have Javascript on so no big issue....) Perhaps #2 is best here?
F. I think the specification of "free selection order" means I have to download most of the database initially, so perhaps I should try to avoid that option.....if I keep it I might as well use method #1, or???
G. It would be best to do as much as possible of the selction/filtering in SQL to allow future extensions by building custom SQL code, so that gives a big minus to #1...
H. Other pitfalls etc???
I have found tutorials etc for all three methods, but if you can point to good resources like this I would appreciate it, especially so I dont base my code on examples that are not smart/good/compatible....
1:
http://www.bobbyvandersluis.com/articles/unobtrusivedynamicselect.php
http://javascript.about.com/library/bl3drop.htm
http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_20523133.html
2:
http://www.plus2net.com/php_tutorial/php_drop_down_list.php
http://www.plus2net.com/php_tutorial/php_drop_down_list3.php
3:
http://techinitiatives.blogspot.com/2007/01/dynamic-dropdown-list-using-ajax_29.html
http://www.webmonkey.com/tutorial/Build_an_Ajax_Dropdown_Menu
http://www.noboxmedia.com/massive-ajax-countryarea-drop-down-list/
http://freeajaxscripts.net/tutorials/Tutorials/ajax/view/Create_AJAX_Dynamic_Drop_Down_List_using_PHP_-_xajax.html
3+jQuery:
http://remysharp.com/2007/01/20/auto-populating-select-boxes-using-jquery-ajax/
Now to the question: Could anyone experienced in all these methods help me out a bit, with the evaluation of methods 1-3 above so I can choose one and get started on the right track? Also, will I be helped by learning/unsing a framework like jQuery+jSON for this?
Rgds
PM
I'd definitely recommend using AJAX with jQuery its tested in all of the major browsers and has simple calls that will make it a lot faster to code and you wouldn't have the browsers compatibility problems of normal JavaScript.
Send all data to the browser and handle the filtering etc client side
with Javascript.
You mentioned that your table has 30 columns and 500-5000 rows potentially? In that case it would not be a good idea to send that much data when the page loads as: 1. It will make the page slower to load and 2. It is likely to make the browser hang (think IE).
Send parameters back to the server after each selection and reload the
whole form after each selection.
Probably a littebit Javascript and
most code in PHP.
I'm not sure how this differs much from the third approach, but probably you mean that you need to reload the page? In that case it isn't likely to be a good user experience if they need wait for the page to refresh every time a drop down selection is changed..
Use AJAX to change all list content
dynamically without reloading the
whole form.
By far the best approach from a user's perspective as it makes filling out the form simple. Perhaps slightly harder to implement from your end, but as you would likely need to perform the same calculations with each of the solutions - might as well move them to a separate page that can be called by AJAX to retrieve your data. As others have mentioned, using jQuery for all your JavaScript/AJAX stuff is going to make things a hell of a lot easier ;)
My personal recommendation is to go with AJAX.
Raw SQL or not is really a question of what backend you are using.
You need to be able to set the relationships between the different selections. The population of the lists must be able to communicate with your backend.
The real issue here is how you implement the relationships between selections. I have no good answer here, it depends heavily on the backend and your administrative needs. It can be hard coded in PHP or configured via XML or via administrative interfaces and persisted to your database solution.
It's no easy task to make it fully customizable.
The reason why i suggest using AJAX is basically because you need to filter upon any change in any selection. That would mean either download a lot of unused information or a lot of page refresh. Going with ajax gives the user a smooth experience all the way.
jquery is a simpple way to use... You can also try a particular class called xajax..! These will make stuff easier.

Categories