Take the data from the database and put it in the table. PHP has its own method, such as Odbc_result_all (), which is used to convert the obtained data into an HTML table format, but it must be the selected field in the SQL statement, and the data that may be displayed is not the field you have selected. Others may have to choose, or judge. So I wrote this code to generate a table. The field you want to display is controlled entirely by an array. And you can change the value of a field in the array as needed. The code is as follows:
/* showtable.php
*
* Created by Xu Jie
* date:03/01/2001
*/
function Showheader ($arr _header)
{
$col = sizeof ($arr _header);
echo "";
Do
{
echo "". POS ($arr _header)."";
}
while (Next ($arr _header));
echo "";
}
function Showlist ($head, $arr _data)
{
$i = 0;
Do
{
$header [$i + +] = key ($head);
}
while (Next ($head));
for ($i =0; $i {
if ($i%2==0)
echo "";
Else
echo "";
for ($j =0; $j {
if ($arr _data[$i]-> $header [$j]!= "")
echo "". $arr _data[$i]-> $header [$j]. "";
Else
echo "";
}
echo "";
}
}
function showtable ($arr _header, $arr _list, $face = "Border=1")
{
echo "";
Showheader ($arr _header);
Showlist ($arr _header, $arr _list);
echo "";
}
?>
Where the user needs to invoke the Showtable () function.
The parameter $arr_header is the header row of the table header. such as a list of users (Username,password,emailadd,homepage),
On SQL Server, Mssql_fetch_object () takes out the field from the database and stores it in an array $arr_list, if only
You want to display username,emailadd,homepage three fields without displaying the password field.
$arr _header can write like this:
$arr _header = Array ("UserName" and "User name", "Emailadd" and "e-mail", "homepage" and "personal homepage");
Then call Showtable ($arr _header, $arr _list; " Border=2 ");
You can display the list on the page. is displayed for the following:
User name Email Personal home Page
...... ........ ........
...... ........ ........
...... ........ ........
If you want to add a link to each e-mail message, you can use a loop to add a link to each of the Emailadd columns.
http://www.bkjia.com/PHPjc/532162.html www.bkjia.com true http://www.bkjia.com/PHPjc/532162.html techarticle take the data from the database and put it in the table. PHP has its own method, such as Odbc_result_all (), which is used to convert the obtained data into an HTML table format, but it must be in an SQL statement ...