Skip to main content

Posts

PHP#25MySQL#21 - Hướng đối tượng Phần 1 - Xây dựng Hàm - Tin theo Loại - Class

<!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> </head> <body> <?php  include("../connect.php"); //Xây dựng hàm: hàm nhận tham số đầu vào là id của 1 loại  và hàm trả về danh sách các tiêu đề tin thuộc loại tin đó: function tin_loai($idLT) { global $link; //biến toàn cục $sl="select * from tin where idLT=$idLT"; $kq=mysqli_query($link,$sl); while($d=mysqli_fetch_array($kq)) { echo $d['TieuDe']."<br/>"; } } echo "Các tin của loại tin có id=1: <br/>"; tin_loai(1); ?> </body> </html>

PHP#25MySQL#21 - Hướng đối tượng Phần 1 - Xây dựng Hàm

<!doctype html> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> </head> <body> <?php  /*//Xây dựng hàm: function ten_ham(các_tham_số) { //Thân hàm: chứa các lệnh return giá trị; //có thể có hoặc không }*/ //Hàm không có return: function tinhtong($ts1, $ts2) { $tam=$ts1+$ts2; echo "Kết quả là: $tam <br/>"; } //Gọi hàm: tinhtong(15,7); tinhtong(23,48); //Hàm có return: function tinhtong2($ts1, $ts2) { $tam=$ts1+$ts2; return $tam; } //Gọi hàm : Đối với dạng có return: $kq1=tinhtong2(57,18); echo $kq1; ?> </body> </html>

PHP#24MySQL#20 Cookie, Xử lý, Ý kiến bạn đọc, bình luận

PHP#23MySQL#19 - Đăng nhập, Session, Thoát user, Xử lý

PHP#22MySQL#18 - Xóa, Sửa TIN & admin index (thể loại, loại tin)

//tin.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <?php if(isset($_GET['lang'])) $lang=$_GET['lang'];   else $lang="vi"; ?> <form id="form1" name="form1" method="get" action="">   <p>     <label for="lang">Ngon ngu:</label>     <select name="lang" id="lang" onchange="form1.submit()">       <option value="vi">Viet</option>       <option value="en" <?php if($lang=="en") echo "selected";?>>English</option>     </select>   <...

PHP#21MySQL#17 - Upload, Xử lý, Thư viện, chèn Ckeditor

//upload.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta  charset="utf-8" /> <title>Untitled Document</title> <script type="text/javascript" src="ckeditor/ckeditor.js"></script> </head> <body> <form action="process.php" method="post" enctype="multipart/form-data" name="form1" id="form1">   <p>     <label for="upImg">Chon anh:</label>     <input type="file" name="upImg" id="upImg" />   </p>   <p>     <label for="MoTa">Mo ta:</label>     <textarea name="MoTa" id="MoTa" cols="45" rows="5" class="ckeditor"></textarea>   </...

PHP#21MySQL#17 - tin_them.php, process.php - Thêm tin mới, Xử lý tin mới

 //tin_them.php <!doctype html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <script type="text/javascript" src="ckeditor/ckeditor.js"></script> </head> <body> <?php include("../connect.php"); if(isset($_GET['lang'])) $lang=$_GET['lang']; else $lang='vi'; ?> <form id="form1" name="form1" method="get" action=""> <p> <label for="lang">Ngon ngu:</label> <select name="lang" id="lang" onchange="form1.submit();"> <option value="vi">Viet</option> <option value="en" <?php if($lang=='en') echo "selected='selected'";?>>Anh</option> </select> </p> <p> <l...