如果我能解決這個問題,我會被詛咒的,我已經看了它太久,可能錯過了一些明顯的東西。沒有在課堂上設置變量
變量表和順序沒有設置,也沒有推送數組中的字段。任何人都可以在此找到任何東西嗎
頁
<?php
$table = new table;
$table->table = "db_firstaid";
$table->order = "aid_date";
$table->field("aid_id","false",NULL);
$table->field("aid_patient","true","[F]");
$table->field("aid_aider","true","[F]");
$table->field("aid_date","false","[F]");
$table->field("aid_time","false","[F]");
$table->table();
?>
類
<?php
class table{
/* Connect */
private $salt = '#######'
private $user = '#######'
private $pass = '#######'
private $host = '#######'
private $data = '#######'
private $db = '';
private $link = NULL;
private function connect(){
$this->link = mysql_connect($this->host, $this->user, $this->pass);
if(!$this->link){
die("<script type=\"text/javascript\">notyfy({text:'Error, could not connect to server.',type:'error',timeout:7000,});</script>");
}
$this->db = mysql_select_db($this->data,$this->link);
if(!$this->db){
die("<script type=\"text/javascript\">notyfy({text:'Error, could not connect to database.',type:'error',timeout:7000,});</script>");
}
}
private function disconnect(){
mysql_close($this->link);
}
/* Push fields into array */
private $fields = array();
public function field($f,$aes,$t){
return $this->fields[] = array($f,$aes,$t);
}
/* Compile SQL string */
public $table = '';
public $order = '';
private $sql = '';
private function genSQL(){
foreach($this->fields as $f){
if($f[1] == 'true'){
$this->sql = $this->sql . "AES_DECRYPT(".$f[0].",'[SALT]') AS ".$f[0].", ";
}else{
$this->sql = $this->sql . $f[0].", ";
}
}
$this->sql = substr($this->sql,0,-1);
$this->sql = "SELECT ".$this->sql." FROM ".$this->table." ORDER BY ".$this->order;
}
/* Query Database */
private $result = '';
private $number = '';
private function query(){
$this->genSQL();
$this->result = mysql_query($this->sql,$this->link) or die(mysql_error());
$this->number = mysql_num_rows($this->result);
}
/* Echo Table */
public function table(){
$this->connect();
$this->query();
if($this->number > 0){
while($row = mysql_fetch_array($this->result)){
echo "<tr class=\"selectable\">";
//Ignore this bit, yet to build.
echo "</tr>";
}
}
$this->disconnect();
}
}
您是否嘗試過調試? – sgroves
你怎麼知道他們沒有設置? – Laurence
@rid oops。碰上我最後的評論,雖然... – shennan