<?
function conn_db($host,$uname,$passwd,$dbname){
$db = mysql_connect($host,$uname,$passwd)
or die(errmesg("Unable to make connection to server."));
mysql_select_db($dbname,$db);
return $db;
}
function add_data($data,$table){
$query = "insert into $table values(";
list($key,$value) = each($data);
$query = $query."'$value'";
while(list($key,$value) = each($data))
$query = $query.",'$value'";
$query = $query.")";
return $query;
}
function get_discuss($table,$field,$begin,$end){
$query = "select postid,title,poster,date from $table where $field<='$begin' and $field>'$end' order by $field desc";
return $query;
}
function check_num_discuss(){
$query = "select * from question";
return $query;
}
function check_data($table,$value){
$query = "select * from $table where postid='$value'";
return $query;
}
function get_ans($value){
$query = "select * from answer where postid='$value' order by ansid asc";
return $query;
}
function data_row($query,$choice){
$str = "";
$db = conn_db(HOST,UNAME,PASSWD,DBNAME);
$result = mysql_query($query,$db);