A Yahoo Answers question here, thanks, reminded me of the fact that there are many more than one set of software components you can use to get similar results when using that dynamic Fred and Ginger team of PHP and MySql.
So today we build off the mysql functional approach as presented some time back with PHP and MySql via MAMP Primer Tutorial to expand on this subject by showing a similar scenario, of fetching database records from a MySql table, and use code for …
- mysql (functional style) … good link here
- mysqli (object OOP style) … good link here and here
- PDO (object OOP style) … good link here and here
… to achieve the same result in three different ways, and, am sure, you can think of some more combinations.
As you can see, PHP and MySql make a great team indeed!
Link to downloadable PHP source code is three_mysql_approaches.php
Previous relevant PHP and MySql via MAMP Primer Tutorial is shown below.
PHP is a server-side language hankering to do database and file management at the server?
Unfortunately this can not be done with a handkerchief alone, as you will also need a database like MySql.
What else is needed? A framework to act as a web server, and for our purposes on this tutorial, on a Mac laptop, we are going to use MAMP.
So we will first show you the MAMP environment for PHP and MySql where we are talking about URLs like http://localhost:8888/ ( or http://127.0.0.1:8888/ ).
Then we will show you a MySql database and table that we will access later via PHP.
Then we will show you two simple PHP scripts to ask for requirements from the MySql database, and one to report on the results of running that SQL query on that MySql database.
Grasp these concepts and a lot of functionality opens up. Imagine what you could do with Ajax techniques.
Enjoy the tutorial.
A great book for this subject is
Professional PHP Programming by Jesus Castagnetto, Harish Rawat, Sascha Schumann, Chris Scollo, Deepak Veliath
Link to downloadable source code of PHP above is ourmysql_test.php and ourmysqltest.php which you need to rename in order to try.
Here is a lifesaver of a link, perhaps.
If this was interesting you may be interested in this too.
If this was interesting you may be interested in this too.