//Tạo form cho phép người dùng nhập vào số dòng, số cột và nút thực hiện. Khi người dùng click nút thực hiện, dữ liệu trên form sẽ truyền qua file xử lý và hiển thị 1 bảng có số dòng, số cột tương ứng
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
<form action="post2_xuly.php" method="post" id="form2">
<label>Nhập số dòng:</label>
<input name="dong" type="text" id="dong" size="30">
<label>Nhập số cột:</label>
<input name="cot" type="text" id="cot" size="30">
<input name="submit" type="submit" id="submit" value="Thực hiện">
</form>
</body>
</html>
//post2_xuly.php
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
<?php
if(isset($_POST['dong'],$_POST['cot']))
{
$d=$_POST['dong'];
$c=$_POST['cot'];
?>
<table width="600" border="1">
<tbody>
<?php
for($i=1;$i<=$d;$i++)
{
?>
<tr>
<?php
for($j=1;$j<=$c;$j++)
{
?>
<td> </td>
<?php } ?>
</tr>
<?php } ?>
</tbody>
</table>
<?php } ?>
</body>
</html>
//CÁCH 2: dùng Mảng để in bảng: https://diendanwebsite.blogspot.com/2021/12/blog-post.html
0 comments:
Post a Comment