Jump to content

Why Php And Mysql? Are They Necesary?


josh.isCool()

Recommended Posts

OK so I've been through all of the AJAX tutorials and I was wondering why they all used PHP and MySQL to generate the XML files that the examples then parse.Couldn't you just directly load the XML files?I could see how a database would be useful for a more complicated application but do you have to use one?My other issue is I'm new to AJAX and XML and I wasn't looking forward to layering two more languages on top of that.I want to learn them eventually but for now I just want to keep it simple.

Link to comment
Share on other sites

Hi JoshI'm also newbie, but it seems you're more newbie than me. :) I'll try to explain you some things, but time should show you I'm right.MySql is structured query language, where you store your data. Everything, just everything: text, pictures, all kind of graphics.You can keep all your net 'welt' on databases.When you make pages, design any kind of activities, you need php code to give a form, insert, design, write any kind of thing you mean is useful for you.Through php code, you upload, download, fetch and do many other things, which later on, when you learn these things, you'll notice make your job easy and safe.Try to download xampp (three servers in one), there you have phpmyadmin, a wonderful co relation between php and mysql.I will not attract your attention, better first get informed, do some exercises, and then ask more. Without these two things, forget, just forget to do anything serious on web.Courage and go on. :)

Link to comment
Share on other sites

My other issue is I'm new to AJAX and XML and I wasn't looking forward to layering two more languages on top of that. I want to learn them eventually but for now I just want to keep it simple.
Then stop it right here (right before AJAX). This is not something for everyone, despite the various "frameworks" that try to "simplify" it. It's not AJAX itself that is complicated, it's the whole process. AJAX is just like the old school's DHTML - it's not a language, it's just a technique for combining multiple languages in a special workflow for a certain purpose.Stop reading right now if you're not already aware of all of the following things (i.e. REALLY know how to work with them; most importantly their syntax and place in web pages workflow) - PHP, JavaScript, HTTP*, XML, XHTML, XML DOM (HTML DOM is a plus).
OK so I've been through all of the AJAX tutorials and I was wondering why they all used PHP and MySQL to generate the XML files that the examples then parse.Couldn't you just directly load the XML files?
That's like asking "Why use variables? Can't you just write the value directly?" or "Why use PHP at all? Why not just plain HTML (maybe with SSI to copy common HTML on multiple pages)?". Every time you use PHP instead of using the plain thing, the answer is "To allow the output to vary depending on a user supplied value or to have a different output at different times" ("output" means anything that HTTP can deliver, since PHP can generate more than HTML).This also applies to AJAX. What "AJAX" is is a technique (as said above). It means for JavaScript to send an HTTP request to the server, upon which the server may return something. JavaScript can then use it to alter the HTML in some way (e.g. the server may return HTML, and JavaScript may just place that HTML within the existing one).
I could see how a database would be useful for a more complicated application but do you have to use one?
No, but since large (and truly useful) applications are unlikely to store their data in a plain array for various reasons, using databases is the most realistic way to teach AJAX.*The HTTP specificaiton is an interesting read, but maybe a little more friendly one is the Wikipedia article on HTTP. In addition, to "see" HTTP, I reccomend that you use Fiddler (see my signature). Be sure to check out the "Raw" tab.
Link to comment
Share on other sites

ouch OK I can see I asked a bunch of stupid questionsguess its on to more tutorialsI'm just trying to make something for a school web design class (extremely basic all we've been taught is Dreamweaver so I've been trying to teach myself some more complicated stuff)For the site I'm making at school I need to finish quickly but since I don't have a clue what I'm doing I guess I just stick with doing things manually and work on learning PHP and MySQL because I eventually plan to make a more advanced version for my own personal website

Link to comment
Share on other sites

Job one: get off Dreamweaver. I mean, you need it for school. So keep it as long as you have to.But when you're on your own, drop it. Or just use the text editor, never the visual editor. It lies. And NEVER, EVER let it create javascript or CSS for you. They include that kind of stuff for idiots who won't ever look at their code -- but machine generated scripts are very hard to update, manage, edit.It's an abomination that they teach that way in school. Not your fault. The whole world's insane.

Link to comment
Share on other sites

Job one: get off Dreamweaver. I mean, you need it for school. So keep it as long as you have to.But when you're on your own, drop it. Or just use the text editor, never the visual editor. It lies. And NEVER, EVER let it create javascript or CSS for you. They include that kind of stuff for idiots who won't ever look at their code -- but machine generated scripts are very hard to update, manage, edit.It's an abomination that they teach that way in school. Not your fault. The whole world's insane.
Don't worry I know enough to understand just how horrible it is to use Dreamweaver. Whenever my teacher is watching I will use it but as soon as she turns away I go back to Note Pad. The way she teaches is just stupid too. We don't learn how to do things. We just copy examples from a book and the things she has us do are so simple they are almost useless. So I spend my free time in that class (which is pretty much the whole time) looking up tutorials for some more complicated aspects of web design.Unfortunately I do still have to get stuff done so I have been using the learn-as-you-go method, which I now see is not the best.
Link to comment
Share on other sites

Actually, learn as you go is not terrible. I know I'm much more motivated to learn a new concept if I need it, than if it's just something for down the road. But once you do need it, that's the time to dig out the books and really learn it. Like, you were asking about server-side languages. Put them off till you need them. But when the time comes, commit yourself.

Link to comment
Share on other sites

I think I should explain that what I was planning to do was to have a bunch of different XML files with the same structure so I could load them into a shell page based on the user's actions.I guess it was supposed to be a "database" of individual XML files rather than one single MySQL database.

Link to comment
Share on other sites

I think I should explain that what I was planning to do was to have a bunch of different XML files with the same structure so I could load them into a shell page based on the user's actions.I guess it was supposed to be a "database" of individual XML files rather than one single MySQL database.
That's an approach similar to what I use myself... and it works quite well. No need for AJAX though. PHP alone can do that (and that's how I do it). You could use JavaScript to change the URL as you make HTTP requests, but only IE8 (and I think Firefox 3?) support this. For older browsers, if you use AJAX and the user presses the back button, they'd go on the page they were before the AJAX started, which if you build a whole site that way means they'd go back to the previous site they were visiting... not exactly a great user experience.
Link to comment
Share on other sites

My idea was to use the URL to determine which XML file would be loaded into the page.I was looking at THIS as an example for how to change the page based on the URL, but instead of using it to write content to the document I was going to use it to change the value of the Javascript variable that held the location of the XML file.

Link to comment
Share on other sites

My idea was to use the URL to determine which XML file would be loaded into the page.I was looking at THIS as an example for how to change the page based on the URL, but instead of using it to write content to the document I was going to use it to change the value of the Javascript variable that held the location of the XML file.
You're overcompicating it. This approach will give you no benefit, as when you change the URL (by clicking on a link, or with JavaScript's window.location), you need to reload the page. At that point, you get a new file. Having to load the same file again, so that you can then get another file with JavaScript means your pages will load slower, because the JavaScript has to be reloaded into the browser, and only then must the file be fetched and rendered.By caching your page with ETag or Expires headers, you may reduce the overhead a little, but you'll still have the burden of making the actual HTTP request (and/or checking the browser's cache).If you do all of that processing on the server though, you won't have that overhead - you'll make the HTTP request (and/or cache checking) either way, but at least the content will be rendered right away.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...