Read Data table content with function and put it into two-dimensional array
Source: Internet
Author: User
Read the data table content by using the function into a two-dimensional array // read the data table content by using the function into a two-dimensional array
// Dynamic SQL statement
// Take the number of read clicks as an 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 content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.