<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body >
<?php
/*
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.
*/
?>
<?php
if(isset($_POST['dong'],$_POST['cot']))
{
$d=$_POST['dong'];
$c=$_POST['cot'];
$m=$_POST['mau'];
echo "<table border='1' width='80%' bgcolor='$m'>";
for($i=1;$i<=$d;$i++)
{
echo "<tr>";
for($j=1;$j<=$c;$j++)
echo "<td> </td>";
echo "</tr>";
}
echo "</table>";
}
else {
?>
<form id="form1" name="form1" method="post" action="">
<p>
<label for="dong">Số dòng:</label>
<input type="text" name="dong" id="dong">
</p>
<p>
<label for="cot">Số cột:</label>
<input type="text" name="cot" id="cot">
</p>
<p>
<label for="mau">Màu nền:</label>
<select name="mau" id="mau">
<option value="blue">Xanh</option>
<option value="red">Đỏ</option>
<option value="yellow">Vàng</option>
</select>
</p>
<p>
<input type="submit" name="taobang" id="taobang" value="Tạo bảng">
</p>
</form>
<?php } ?>
</body>
</html>
0 comments:
Post a Comment