After many many days, today early in the morning, I found some time to make a connection to a MySql Database and do some PHP.
It was a good experience all together. After all, now, for the time being, I’m busy doing some database operation in ASP.NET.
In the midst of ASP.NET, some PHP and MySql brings a fresh breeze.
Now for the people who want to do some database operation in PHP, I’d like to share my experience.
Besides, I’ll give an example of ASP.NET database operation so that readers can compare the pros and cons of two great dynamic web language.
First PHP. The code is very simple:
A MySql Database Connection Made
Database name is ‘produce’, table is ‘products’ which has three columns
$connection = mysql_connect("localhost", "root", "") or die("Could not connect");
$db = mysql_select_db("produce", $connection) or die("Could not select database");
$query = "SELECT * FROM products";
$result = mysql_query($query);
|Product ID||Product Name||Product Number|
|“, $row[‘productID’], “||“, $row[‘productName’], “||“, $row[‘ProductNumber’], “|
It looks like this:
In ASP.NET, if I want to do the same thing, I don’t have write a single code! The fun of that web language lies there. There are so many options to connect to the Database, be it Oracle, MSSQL or anything else, and there is also so many options to operate that database through various data source controls, that in PHP the lazy programmers will definitely feel the heat! 🙂