- Download and install WAMP (Windows Apache MySQL PHP) Server at www.wampserver.com/en or you can use other server package that supports MySQL and PHP applications (ex. AppServ, LAMP, etc.)
- Once installed, make sure that your localhost is up and running and try to access http://localhost
- Read the manual on how to create and where to save your PHP webpages. For WAMP, go to the installation directory and locate the “www” folder.
- Enjoy creating dynamic web applications using PHP & MySQL.
COMMON PHP/MYSQL FUNCTIONS:
| MySQL Function | Example |
| mysql_connect(host, username, password) | mysql_connect(“localhost”, “root”, “admin”) ; |
| mysql_select_db(database_name) | mysql_select_db(“accounts”); |
| mysql_query(query_statement) | mysql_query(“SELECT * FROM users”); |
| mysql_fetch_array(query_result) | $query = “SELECT * FROM users”;
$result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)) { echo $row['fname']. ” “. $row['lname']; echo “<br />”; } |
| mysql_affected_rows() | $query = “SELECT * FROM users WHERE age>18″;
$rows = mysql_affected_rows(); echo “Total Records: “.$rows; |
| mysql_close(identifier) | $connection = mysql_connect(“localhost”, “root”, “admin”) ;
mysql_close($connection); |
Note: For more details MySQL functions for PHP, visit http://www.php.net/manual/en/ref.mysql.php
MYSQL STATEMENTS:
| MySQL Statement | Format | Example |
| INSERT | INSERT INTO table_name(fields) VALUES(values) | mysql_query(“INSERT INTO users(name, age) VALUES(‘Jerome Locson’, ‘27′ ) “) ; |
| SELECT | SELECT fields FROM table_name [additional _conditions] | mysql_query(“SELECT * FROM users WHERE age>18″) |
| UPDATE | UPDATE table_name SET conditions | mysql_query(“UPDATE users SET age=’22′ WHERE age=’21′”); |
| DELETE | DELETE FROM table_name WHERE conditions | mysql_query(“DELETE FROM users WHERE name=’Jerome Locson’”) |










