//得到数据表的信息 /* $result[]: * [0]["table"] table name * [0]["name"] field name * [0]["type"] field type * [0]["len"] field length * [0]["flags"] field flags */ function MetaData($table=''){ $count = 0; $id = 0; $res = array();
...................... $this->_conn->setfetchMode(ADODB_FETCH_ASSOC); $data = $this->_conn->GetAll("select name,id............... from ..."); foreach($data as $value) echo $values['name']; ........................我也同意楼上的看法,很佩服唠叨的知识面和精通度 我决定有机会敲晕他,然后和他换脑袋.....
Set Adors_mysql = Adocon_mysql.Execute("select * from tablename") For i = 0 To Adors_mysql.Fields.Count - 1 Text1.Text = Text1.Text & Adors_mysql.Fields.Item(i).Name Next i其实这个问题你应该去asp去问
$conn = mysql_connect("localhost","user","password");//连接mysql
mysql_select_db("yourstock");//选择库名
$query = "select * from yourtablename where 1";
$result = mysql_query($query);
while($re = mysql_fetch_row($result)){
echo $re[0];//第1个字段
echo $re[1];//第2个字段
//...以此类推。
}?>
/* $result[]:
* [0]["table"] table name
* [0]["name"] field name
* [0]["type"] field type
* [0]["len"] field length
* [0]["flags"] field flags
*/
function MetaData($table=''){
$count = 0;
$id = 0;
$res = array();
if ($table) {
$id = @mysql_list_fields($this->Database, $table);
if (!$id)
$this->Halt("Metadata query failed.");
} else {
$id = $this->query_iD;
if (!$id)
$this->Halt("No query specified.");
}
$count = @mysql_num_fields($id);
for ($i=0; $i<$count; $i++) {
$res[$i]["table"] = @mysql_field_table ($id, $i);
$res[$i]["name"] = @mysql_field_name ($id, $i);
$res[$i]["type"] = @mysql_field_type ($id, $i);
$res[$i]["len"] = @mysql_field_len ($id, $i);
$res[$i]["flags"] = @mysql_field_flags ($id, $i);
}
if ($table) @mysql_free_result($id);
return $res;
}
改写与phplib中数据库class的函数
注意函数:
mysql_field_table
mysql_field_name //取到字段名称
用FetchField取得的字段信息大概是
[name]=>id
[table]=>library
[def]=>
[not_null]=>1如果你取字段名字的话用FetchField['0']试试
或者fetchfield['name'
很佩服唠叨的知识面和精通度
$this->_conn->setfetchMode(ADODB_FETCH_ASSOC);
$data = $this->_conn->GetAll("select name,id............... from ...");
foreach($data as $value)
echo $values['name'];
........................我也同意楼上的看法,很佩服唠叨的知识面和精通度
我决定有机会敲晕他,然后和他换脑袋.....
For i = 0 To Adors_mysql.Fields.Count - 1
Text1.Text = Text1.Text & Adors_mysql.Fields.Item(i).Name
Next i其实这个问题你应该去asp去问
在我没有发现 FetchField 之前,我是用 Array_keys(); 来取字段,即 $conn -> FetchMode( ADODB_FETCH_ASSOC );
$rsASSOC = $conn -> execute( $sql );
$keys = array_keys( $rsASSOC -> fields ); 感谢 feixuehenshui(飞雪恨水) 提供对 FetchField 方法的详细解释 xumail(笑傲江湖) 提到的到 ASP 论坛去问,但我用的是 Apache 服务器,所以无法用 ASP,我初学网页后台也是从 ASP 开始,只是后来大环境是 Apache,所以只得改用 PHP. 感谢 jaexc(大飞) 提供详细的在 Phplib 下的用法,如果 Phplib 有足够的魅力吸引我转向它的话,我会给你加分的 hahawen(变态的大龄青年, 越来越变态,咋办啊) 的方法跟我差不多,但看起来有点伤脑筋,同样感谢