Ini adalah fungsi memperoleh tipe data mysql:
this function will return mysql type ( int,varchar,text, etc..) when you call like this:
$id_type = get_field_type('chats','id');
function field_type($rectype){
$artype = explode('(',$rectype);
return $artype[0];
}
function get_field_type($tablename,$fieldname){
$res = ”;
$sql = “SHOW COLUMNS FROM `”.$tablename.”`”;
$qry = mysql_query($sql);
if($qry){
$reccount = mysql_num_rows($qry);
if($reccount>0){
while($row=mysql_fetch_array($qry,MYSQL_ASSOC)){
if($row['Field']==$fieldname){
$res = field_type($row['Type']);
break;
}
}
}
}
return $res;
}
salam bahagia







































