Home > Backend Development > PHP Tutorial > Implementation code of PHP output table (revised version)_PHP tutorial

Implementation code of PHP output table (revised version)_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-21 15:32:36
Original
984 people have browsed it

Many codes on the Internet are wrong, and Script House has specially corrected them.

Copy code The code is as follows:



Two rows and five columns, a total of 10 data



< tr>
$num = 5; //Currently displays the number of columns in each row
$k = 1; //Initialization
while($k<=10)
{
if($k % $num == 0){
if($k==10){
echo '< /tr>'."rn";
}else{
echo ''."rn";
}

}
else {
echo ''."rn";
}

$k+=1; //Add
}
?>
'.$k.''.$k.'
'.$k.'




The following is read from the database:
Copy the code The code is as follows:

$sql = "select * from table ";
$query = mysql_query($sql);
$num = mysql_num_rows($query);
for($i=0;$i <$ num;$i++) {
$result = mysql_fetch_array($query);
if($i%3==0){
$str.= " ";
}
$str.= " ".$result[ "title "]. " ";
if(($i +1)%$num==0) {
$str.= " ";
}
}
?>

echo $str;
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/322763.htmlTechArticleMany codes on the Internet are wrong, and Script House has specially corrected them. Copy the code. The code is as follows: html head title, two rows and 5 columns, a total of 10 data/title /head body table border="1" width=8...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template