Skip to main content

Posts

Showing posts from December 5, 2021

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

//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">...

$_POST nhập vào 1 số, in ra bảng cửu chương của số đó

//Nhập vào 1 số, in ra bảng cửu chương của số đó <!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> </head> <body> <form action="post_xuly.php" method="post" id="form1" name="form1"> <label>Nhập 1 số:</label> <input name="so" type="text" id="so" size="30"> <input name="submit" type="submit" id="submit"> </form> </body> </html> //post_xuly.php <!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> </head> <body> <?php if(isset($_POST['so'])) { $so=$_POST['so']; for($i=1;$i<=10;$i++) echo "$so x $i =".($so*$i)."<br/>"; } ?> </body> </html>

$_POST['name']

$_POST['phầntử'] $_POST  : là 1 mảng bắt dữ liệu từ form qua phầntử   có chỉsố  : là đối tượng  name  từ form qua //  giátrị  của phầntử là  value  của name

Dùng FORM nhập số dòng, số cột & Dùng mảng in ra số dòng số cột đó.

  <!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> </head> <body> <form method="post" id="form1" name="form1" action="">    <label>Nhập số dòng: </label>      <input name="dong" type="text" id="dong" > <label>Nhập số cột: </label> <input name="cot" type="text" id="cot" > <input name="submit" type="submit" id="submit" value="Thực hiện" > </form> <?php if(isset($_POST['dong'],$_POST['cot'])) { $d=$_POST['dong']; $c=$_POST['cot']; $a=array(); for($tr=0;$tr<$d;$tr++) for($td=0;$td<$c;$td++) $a[$tr][$td]=rand($d,$c); echo "<table width='600' border='1'>"; for($tr=0;$tr<$d;$tr++) { echo "<tr>...