Blogger Information
Blog 35
fans 0
comment 0
visits 27396
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
php编辑表格生成器,for循环编写乘法口诀
小的博客
Original
1032 people have browsed it

QQ截图20171226224747.png

一,上面是代码的图片预览;

<?php
 header('Content-Type:text/html;charser=utf-8');//设置表头,字体为utf-8
echo <<<'INPUT'
   <form action=''>//生成表单
     请输入行<input type=text name='row'>列<input type="text" name="col"><input type="submit" value='提交'>
   </form>
INPUT;
 $row=isset($_GET['row'])?$_GET['row']:null;//取值,获取表单提交过来的get方式接受到的值
   $col=isset($_GET['col'])?$_GET['col']:null;//取值,获取表单提交过来的get方式接受到的值
   //分别判断接受过来的行和列的值是否为空
   if(empty($row)){
    echo '<script>alert("请输入行")</script>';
    exit;
   }
   if(empty($col)){
    echo '<script>alert("请输入列")</script>';
    exit;
   }
echo '<table border="1" cellpadding="0" cellspacing="0" width="400">';
  //利用双层for 循环添加表格
   for($i=0;$i<$row;$i++){
    echo '<tr>';
    for($j=0;$j<$col;$j++){
     echo '<td>'.($i*$j+$j).'</td>';
    }
    echo '</tr>';
   }
echo '</table>';
//利用双层for循环编写乘法口诀
for($i=1;$i<=9;$i++){
 for($k=1;$k<=$i;$k++){
  echo $i.'x'.$k.'='.($i*$k);
  
 }
 echo'<br/>';
}
?>


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post