You may be rightHere is the specific operation code:
- Php
- $ Connection = mysql_connect ("localhost", "Albert", "Shhh");
- mysql_select_db ("Winestore", $connection);
- $ result = mysql_query ("Select cust_id, Surname,
- FirstName from Customer ", $connection);
- While ($row = mysql_fetch_array($result))
- {
- echo "id:t{$row [" cust_id "]}n";
- echo "surnamet{$row [" Surname "]}n";
- echo "First name:t{$row [" FirstName "]}nn";
- }
- ?>
The function mysql_fetch_array () puts a row of query results into an array, which can be referenced in both ways, for example cust_id can be used in the following two ways: $row ["cust_id"] or $row[0]. Obviously, the former is much more readable than the latter.
In the case of multiple-table links in the query results of the PHP associative array, if the two column names are the same, it is best to separate them with aliases:
SELECT Winery.name as Wname,
Region.name as Rname,
From winery, Region
WHERE winery.region_id = region.region_id;
The column names are referred to as: $row ["Wname"] and $row ["Rname"].
In the case of specifying table and column names, only column names are referenced:
SELECT winery.region_id
From Winery
The reference to the column name is: $row ["region_id"].
A reference to a clustered function is the reference name:
SELECT COUNT (*)
from customer;
The reference to the column name is: $row ["Count (*)"].
These are all the specific steps for the query results of the PHP associative array.
http://www.bkjia.com/PHPjc/446371.html www.bkjia.com true http://www.bkjia.com/PHPjc/446371.html techarticle you may be to the following is the specific operation code:? php $ connection = mysql_connect ("localhost", "Albert", "Shhh"); mysql_select_db ("Winestore", $ connection); $ result = Mysql_qu ...