Reading the contents of a data table with a function into a two-dimensional array
Dynamic SQL statements
Take the read-out number of clicks table for example.
function List_hit ($fields, $where, $order, $direction, $limit, $conn)
{
if ($fields = = "") {$fields = "hit_id,banner_id,hit_ip,hit_time";}
if ($order = = "") {$direction = "";}
$sql = "Select $fields from Hit $where $order $direction $limit";
Echo $sql;
$res =mysql_query ($sql, $conn);
$i = 0;
$list _hit[$i] ["Rows"]=mysql_num_rows ($res);
$i + +;
while ($rs =mysql_fetch_array ($res))
{
$list _hit[$i] ["hit_id"]= $rs ["hit_id"];
$list _hit[$i] ["banner_id"]= $rs ["banner_id"];
$list _hit[$i] ["Hit_ip"]= $rs ["Hit_ip"];
$list _hit[$i] ["Hit_time"]= $rs ["Hit_time"];
$i + +;
}
return $list _hit;
}
The above describes how to use the function to read the data table content in PHP into a two-dimensional array, including the reading of the data table aspects, I hope the PHP tutorial interested in a friend helpful.