Help with PHP and Ajax
Moderator: General Moderators
Help with PHP and Ajax
I know nothing of AJAX and I'm trying to learn something that I thought was easy. I was looking for tutorials on automatic form updates with MySQL.
I have a table called records with 5 cols' in each: rec_ID, IP, Device, WattLoad, Cur_Load
There's about 15-20 records.
I have them all being displayed in the page, and what I'd like to do now is the ajax part. I'd like to double click on the IP, Device, watt load, or current load to edit that corresponding col. But I don't know where to begin. I found one VERY close, but it uses a text file instead of a database.
I'd really like some help in this since I'm trying my best to get started with Ajax. Any help would be greatly appreciated.
~RB
I have a table called records with 5 cols' in each: rec_ID, IP, Device, WattLoad, Cur_Load
There's about 15-20 records.
I have them all being displayed in the page, and what I'd like to do now is the ajax part. I'd like to double click on the IP, Device, watt load, or current load to edit that corresponding col. But I don't know where to begin. I found one VERY close, but it uses a text file instead of a database.
I'd really like some help in this since I'm trying my best to get started with Ajax. Any help would be greatly appreciated.
~RB
- n00b Saibot
- DevNet Resident
- Posts: 1452
- Joined: Fri Dec 24, 2004 2:59 am
- Location: Lucknow, UP, India
- Contact:
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
There no quick solution to learning AJAX. If you want to create AJAX application you need to know
- A server side language, PHP
- DOMScripting - JavaScript that doesn't suck
- Knowledge of HTTP, HTML (pref. XHTML) and CSS
- A database, MySQL
- XML and related technolgies such as XPath, SOAP, XSLT, WSDL, etc. to structure the data interchange
- Greater knowledge of PHP in particular OOP
- Knowledge of a good PHP framework is essenuial for synchronizing JS and PHP and any PHP app of a reasonable scale
- Fairly good grounding in PHP and Web security
You may need to be solid in all that to make a large production application but there's no reason you can't pound out something from Ajax tutorials... Most of what was mentioned that you "need to know" you don't "need to know" to make a simple Ajax "application".
Here are the ones I've refered to in the past, not all of them have it perfect, I ended up using techniques from multiples:
http://aleembawany.com/weblog/webdev/00 ... orial.html
http://www.pixel2life.com/twodded/t_aja ... ta_/page4/
http://www.informit.com/articles/articl ... Num=4&rl=1
http://www.onlamp.com/pub/a/onlamp/2005 ... quest.html
- Yes, you need to know some PHP (or other server side language, but really not necessarily, could just be a flat file that XMLHttpRequest gets), HTML, and Javascript.
- You only need to know DOM well if you're using Ajax to process XML output, which isn't necessary. .innerHTML and the Ajax code is about all that's required.
- You don't necessarily need a database
- You don't need to know any of those XML technologies although you can. PHP can output either, so it can just output HTML or just plain text. Use responseText instead of responseXML... Although XML has it's value, it's not needed here and really just adds overhead for something simple.
- No OOP needed, but we won't start that debate again. PHP really plays a lesser roll in most Ajax applications anyways because it's only serving out the relevant portions after it serves out the application initially. Needs to be leaner and meaner to handle increased requests that are inherent in Ajax.
- I don't see why you need a framework to do this. Javascript asks for data just like a browser always has, PHP does its thing and responds back just like it always has but only with relavent data. A Framework might have it's place but probably not here... Use common names between JS and PHP not sure what else you need to synchronize. First word is Asynchronous for a reason : )
- I don't think Ajax changes anything about Web Security that doesn't exist in regular applications. Ajax does add to more things JS can do such as embedding Ajax in text areas that would then run on the admin side when they view the entry when an admin was logged in, effectively performing tasks as the admin, likely without them even knowing the browser is even doing anything, but that affects any web system.
Here are the ones I've refered to in the past, not all of them have it perfect, I ended up using techniques from multiples:
http://aleembawany.com/weblog/webdev/00 ... orial.html
http://www.pixel2life.com/twodded/t_aja ... ta_/page4/
http://www.informit.com/articles/articl ... Num=4&rl=1
http://www.onlamp.com/pub/a/onlamp/2005 ... quest.html
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
I would define an application as a system with input, process and output designed to solve a problem that is less than elementary usually involving at least two user screens and more than one database table.I'm anxious to know what qualifies as an ajax '*application*' in your book....
OK yes I believe I was defining the skills required for a professional AJAX application which I admit may be out of place in this case.You may need to be solid in all that to make a large production application but there's no reason you can't pound out something from Ajax tutorials... Most of what was mentioned that you "need to know" you don't "need to know" to make a simple Ajax "application".
For the most simple of applications you could, yes, get by with very little knowledge of PHP but the second you want to start creating an AJAX application that peforms a couple of different actions, has states and conditions you really should have a degree of familiarity with PHP.Yes, you need to know some PHP (or other server side language, but really not necessarily, could just be a flat file that XMLHttpRequest gets), HTML, and Javascript.
I dispute this. You need to use the DOM in some form or another to get or put any data into an existing HTML document. Understanding the basics of the DOM such as the structure of nodes and the properties each node is likely to have will make these tasks possible without it you will end up copying and pasting code code of forums.You only need to know DOM well if you're using Ajax to process XML output, which isn't necessary. .innerHTML and the Ajax code is about all that's required.
True. But we use databases because they make storage and retreival of structured information easier. It is not likely that without one you would require much greater knowledge of XML, DOM, and PHP in order to store and retreve structured information. I know which I think is easiest. I am again of course referring to a level of varied user interactivity that would be seen in an AJAX application. In the most basic of basic AJAX usage this point may not be true.You don't necessarily need a database
Absolutely. I'm an avocate of this fact. I've put off learning XML and XML based technologies. But once again even I have to admit that building an AJAX application is much easier for those that know and understand XML well this fact become more pronounced as an AJAX application grows in size.You don't need to know any of those XML technologies although you can. PHP can output either, so it can just output HTML or just plain text. Use responseText instead of responseXML... Although XML has it's value, it's not needed here and really just adds overhead for something simple.
I could be really picky and say that you need to use XML in order to be writing AJAX.
Procedural code is better when things are small but if you know OOP and your application is of a resonable size you will benefit from using it. But no you don't *need* OOP in the same way you don't need to write AJAX to make a web application. Also if you are going to provide a AJAX and non-AJAX (for those without JavaScript) functionality for your application you will need to identity areas of code reuse and objects will make this easier. I guess I think of AJAX as while an elitest technology, and the elite should write non-AJAX alternatives with all their AJAX applications and should be worthy of using AJAX.No OOP needed, but we won't start that debate again. PHP really plays a lesser roll in most Ajax applications anyways because it's only serving out the relevant portions after it serves out the application initially. Needs to be leaner and meaner to handle increased requests that are inherent in Ajax.
Asynchronous in this case is referring to the fact that users no longer need to wait for an entire page to load to get what they want. AJAX still requires the synchronization of client and server because you simply cannot avoid the fact that this is still the HTTP protocol where the server and client must work together to deliever something.I don't see why you need a framework to do this. Javascript asks for data just like a browser always has, PHP does its thing and responds back just like it always has but only with relavent data. A Framework might have it's place but probably not here... Use common names between JS and PHP not sure what else you need to synchronize. First word is Asynchronous for a reason : )
Let me give you an example. Say you have a form where your user will fill in their ZIP/Post Code and first line of their address followed by a selection of checkboxes for different pizzas. With AJAX the Zip/Post Code will be validated on the client as will the address but as we all know these validations must be completed on the server otherwise people will be able to spoof your site. So this is going to require some synchronization between client and server namely the validations will have to be the same. The client and server also have to be synchronized in that they need to be able to understand the responses / requests coming from each other.
You're right AJAX doesn't change web security but I wouldn't bulid a professional web application, AJAX or not, without excercising my present knowledge of web security.I don't think Ajax changes anything about Web Security that doesn't exist in regular applications. Ajax does add to more things JS can do such as embedding Ajax in text areas that would then run on the admin side when they view the entry when an admin was logged in, effectively performing tasks as the admin, likely without them even knowing the browser is even doing anything, but that affects any web system.
Yes you're right. I'm clouded somewhat but my attitude to AJAX and my belief that you should only use it when you know what you are doing but on a small scale this can be wavvered and I wish Red Blaze luck with his AJAXy endevours.HTML, JS, Server Side, probably Database, sure you can incorporate far more and make more advanced applications, but that doesn't sound like what the poster needs.
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
No it doesn't and I will state once more that my commented were specific to those who want to build fully-fledged AJAX applications in this case lesser knowledge will be acceptable. I admit in the context of the initial request from Red Blaze I was pretty OT.Word, ole, I was just pointing out that most people make it out to be rocket science when it doesn't need to be. Sure you can make it as comlex as you want, but no need to know all that to get started...
I didn't know about those. They look to require experience with other technologies though, like Java and Oracle Databases.with JDeveloper and ADF pages you don't have to know any of the mentionned technologies and yet, you can create AJAX applications... Just like you can use dreamweaver/frontpage to generate html without knowing html..
They bring BackBase to mind which seems like an excellent way to write AJAX applications if you can afford the license.
Actually, JDeveloper allows one to simply drag-and-drop the components you want on your page.. Or it generates EJB3 entitiy beans from the existing dbschema you feed (simply enter the username, password, hostname, dbtype and off it goes...)ole wrote: I didn't know about those. They look to require experience with other technologies though, like Java and Oracle Databases.
Another example would that you don't need to know the structure of the mp3 fileformat in order to play or make a song encoded with mp3...
If one would need expert knowledge in order to be succesful in it there would no unwanted teenage pregnancies
My point was that in order to use a certain technology you don't have to know all the underlying principles.