MySQL is a database that defines a structure for storing information categorically in tables that contain rows and columns. A database must be selected before tables can be created using the mysql_select_db() function. PHP executes SQL statements using the mysql_query() function and retrieves results as an array using mysql_fetch_array(). Connections to the database are opened with mysql_connect() and closed with mysql_close().
Download as PPT, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
66 views
My SQL
MySQL is a database that defines a structure for storing information categorically in tables that contain rows and columns. A database must be selected before tables can be created using the mysql_select_db() function. PHP executes SQL statements using the mysql_query() function and retrieves results as an array using mysql_fetch_array(). Connections to the database are opened with mysql_connect() and closed with mysql_close().
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 8
Your datasource
MySQL is a database. A database defines a
structure for storing information. In a database, there are tables. Just like
HTML tables, database tables contain rows,
columns, and cells. Databases are useful when storing
information categorically. A company may
have a database with the following tables: "Employees", "Products", "Customers" and "Orders". $con = mysql_connect(servername, username, password); mysql_close($con); <?php $con = mysql_connect("localhost", "peter", "abc123"); if (!$con) { die('Could not connect: ' . mysql_error()); } // some code mysql_close($con); ?> A database must be selected before a table can be created. The database is selected with the mysql_select_db() function. mysql_select_db("my_db", $con); To get PHP to execute an SQL statement we must use the mysql_query() function. $result = mysql_query("SELECT * FROM
person"); Use mysql_fetch_array() function to get the query result as an array. $result = mysql_query(‘SELECT * FROM