This is a super simple PHPMySQL getting started tutorial. you can refer to the SELECT statement to SELECT data from the database and SELECT data from the database table, the SELECT statement is used to SELECT data from the database. syntax: SEL... this is a simple PHP MySQL getting started tutorial. you can refer to the SELECT statement to SELECT data from the database and SELECT data from the database table, the SELECT statement is used to SELECT data from the database.
Syntax: SELECT column_name (s) FROM table_name
Note: SQL statements are case insensitive. SELECT statements are equivalent to select statements.
To allow PHP to execute the preceding statement, we must use the mysql_query () function, which is used to send a query or command to MySQL.
For example, the following example selects all data stored in the "Persons" table (* selects all data in the table). The code is as follows:
";}mysql_close($con);
The above example stores the data returned by the mysql_query () function in the $ result variable. Next, we use the mysql_fetch_array () function to return the first row from the record set in the form of an array, each subsequent call to the mysql_fetch_array () function will return the next row in the record set. the while loop statement will record all records in the set cyclically. to output the values of each row, we use the $ row variable of PHP ($ row ['firstname'] and $ row ['lastname']).
Output of the above code:
Peter Griffin
Glenn Quagmire
The result is displayed in an HTML table. The data selected in the following example is the same as that in the preceding example, but the data is displayed in an HTML table. the code is as follows:
Firstname Lastname ";while ($row = mysql_fetch_array($result)) { echo ""; echo "" . $row['FirstName'] . ""; echo "" . $row['LastName'] . ""; echo "";}echo "";mysql_close($con);
// Output of the above code:
Firstname Lastname Glenn Quagmire Peter Griffin
Address:
Reprinted at will, but please attach the article address :-)