Skip to main content

Posts

PHP#5 - MySQL#1 - Database - Tạo bảng

Tạo database banhang Tạo bảng chungloai có cấu trúc như sau: Thêm các dòng dữ liệu cho bảng chungloai vừa tạo: Lưu database lại với tên shop.sql Sửa thuộc tính AnHien của chủng loại có id =7 thành 0 Xóa chủng loại có id=8 Tạo database mới có tên shoponline import file shop.sql vào database shoponline Tạo bảng loaisp có cấu trúc sau: Thêm các dòng dữ liệu cho bảng loaisp vừa tạo: Lưu database shoponline thành file shoponline.sql

PHP#5 $_GET - click vào Menu, hiện ra nội dung tại Main

 //index <!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> <style> #container{width: 900px; margin: auto; border: 1px solid #2752C7;} #header{height: 100px; border-bottom: 1px solid #2752C7;} #left{width: 200px; float: left; border-right: 1px solid #2752C7; min-height: 300px;} #right{float: right; width: 697px; min-height: 300px;} #footer{height: 50px; clear: both; border-top:1px solid #2752C7; } </style> </head> <body> <div id="container"> <div id="header"><?php include("header.php");?></div> <div id="left"><?php include("menu.php");?></div> <div id="right"> <?php if(isset($_GET['key'])) { switch($_GET['key']) { case "tt": include("tintuc.php");break; case "xh": include("...

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

PHP#4 form_get.php | xuly_form_get.php

//form_get.php <!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> </head> <body> <form id="form1" name="form1" method="get" action="xuly_form_get.php"> <label for="test">Nhập giá trị:</label> <input type="text" name="test" id="test"> <input type="submit" name="submit" id="submit" value="Thực hiện"> </form> <p>Click vào <a href="xuly_form_get.php?test=123">đây</a> để test</p> </body> </html> //xuly_form_get.php <!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> </head> <body> <?php if(isset($_GET['test'])) { echo $_GET['test']; //echo "<br/>".$_GET['submi...