View Full Version : PHP getting a form element

08-25-2008, 05:50 PM
I have a form, and I need to select some stuff out of a database like this

SELECT name FROM misc_a WHERE parent=(form value inserted here)

Then the value that is returned is going to go in a SELECT list so I don't want to reload the page. Is there anyway I can get the form value, without reloading the page, or using Ajax?

08-25-2008, 06:50 PM
You must use ajax, there is no other way to do it without the page reloading.

08-25-2008, 10:31 PM
Nile is correct.

The form would be being displayed in a user's browser on his or her own machine. It has no access to the data on the server. In order to access server data, you need to send a new HTTP request either through ajax, or through a new page load.

If the reason you're shying away from ajax or a new page load is speed, there's an alternative depending on the size of your database. Theoretically, you could select all the rows in the applicable database, and store the data in hidden elements within your page. When they submit the form, you'd prevent the default action, and loop through the hidden data taking only what you need. This would only be feasible with a very small database, but I thought I'd give you the option.

08-26-2008, 02:12 AM
Thanks :)