简体   繁体   中英

Generating Key/value (coulmn name/value) pairs from a MySQL call

My normal way of querying an SQL table (I'm using php) is by implementing the line below:

mysql_query("SELECT * FROM `TABLE_NAME` WHERE SOME CONDITION") or die(mysql_error());

I would like to query in a way that returns key/value pairs where the key is the column name. Can anyone suggest an elegant way to accomplish this.

使用mysql_fetch_assoc()从表中读取行。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM