LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-11-2007, 08:47 AM   #1
true_atlantis
Member
 
Registered: Oct 2003
Distribution: fedora cor 5 x86_64
Posts: 639

Rep: Reputation: 30
Php/ajax/sql


I am about to start a project and would like to include AJAX functionality. The question I have is, how do I go about getting variables to AJAX/Java from PHP/SQL. For example, I want to use the yahoo widget/toolset to dynamically call sql queries to populate lists. I havent read into this much, but my initial thoughts were it would take a bunch of steps

1. call a GET from an external PHP script (which will return hidden variables - values to put in the table)
2. after that is returned, load the variables into the java array that is associated with the table
3. update table


Would that be the correct way of going about doing this, or is there something simpler? Would I want to use PHP to do the SQL stuff?

Any insight into a basic workflow of doing dynamic SQL queries using PHP and getting those results back into an AJAX based list would be helpful. I feel like im missing a main/key idea. Thanks in advance.
 
Old 05-11-2007, 09:03 AM   #2
krizzz
Member
 
Registered: Oct 2004
Location: NY
Distribution: Slackware
Posts: 200

Rep: Reputation: 30
Are you talking about Java or JavaScript? Do you think of Java applet as an alternative to AJAX ? As for the AJAX - it's simple, it let's you do the HTTP requests from JavaScript so you don't need to reload the entire page - you can do in "in the background". You need to create HTTP interface script in PHP, that will receive HTTP requests from your AJAX. After processing in PHP (based on parameters from the request) you can return (echo out) the result in desired format. Then it will be received by your JS response handler function. The preferred format for the result is XML but you can use the plain text too. Then you need to parse it in JS. So the steps would be :

1. Create JS function that makes AJAX request to the server, with given parameters.
2. Create the "response handler" function that processes the result from the AJAX request.
3. Create PHP script that receives HTTP requests with the parameters transported over GET, executes action and prints out the response.
4. Call your request function and wait for response.

Best,
Chris
 
Old 05-11-2007, 01:57 PM   #3
true_atlantis
Member
 
Registered: Oct 2003
Distribution: fedora cor 5 x86_64
Posts: 639

Original Poster
Rep: Reputation: 30
for plugins/toolkits like google and yahoo, do you just need to create the request function and php script, and as long as the return is in the correct format, it will update the table/whatever widget your using?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Will PHP Bring Simplicity to AJAX? LXer Syndicated Linux News 0 03-22-2007 11:31 PM
LXer: PHP for Microsoft AJAX Library released LXer Syndicated Linux News 0 02-24-2007 06:01 PM
LXer: Use Ajax with PHP and object-oriented Xajax LXer Syndicated Linux News 0 02-02-2007 11:03 AM
LXer: Beginning Google Maps Applications with PHP and Ajax LXer Syndicated Linux News 0 09-17-2006 04:33 AM
Where to find a server-side php code that interacts with Ajax? Basel Programming 2 02-05-2006 05:11 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:22 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration