<?php class Class_DB{ private $charset="UTF8"; private $rs; private $_fetch_array = array(); public function __construct($host,$root,$pw,$db_name){ mysql_connect($host,$root,$pw)or die(mysql_error()); mysql_query("SET NAME".$this->charset); mysql_select_db($db_name); echo"connect ok <br/>"; } public function query($strsql){ $this->rs = mysql_query($strsql); } public function num_rows(){ return mysql_num_rows($this->rs); } public function fetch_array(){ if(count($this->_fetch_array)>0){ return $this->_fetch_array; }else{ while($row=mysql_fetch_array($this->rs)){ $this->_fetch_array[]=$row; } return $this->_fetch_array; } } } ?>
<?php session_start(); include_once("lib/config.inc.php"); include_once("lib/class_db.inc.php"); $db = new Class_DB(DB_HOST,DB_ROOT,DB_PW,DB_NAME); $db->query("select*from tb_user"); echo "there are"." ".$db->num_rows()."<hr>"; foreach($db->fetch_array() as $r){ echo"ข้อมูล ".$r['user_id']." : ".$r['username']." : ".$r['password']." : ".$r['nameuser']."</p>"; } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <title>Page Title</title> </head> <body> </body> </html>
public function fetch_array(){ if(count($this->_fetch_array)>0){ return $this->_fetch_array; }else{ while($row=mysql_fetch_array($this->rs)){ $this->_fetch_array[]=$row; } return $this->_fetch_array; } }
เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง