[PHP-DB] Column names into variables
Hi, I have a table with about 50 columns in it. I'd like to query the information for one record, and hold the data in variables that have the same name as the column headings, along these lines: $query = Select * from `postings` where `id` = $userid; $result = mysql_query($query); while($row=mysql_fetch_array($result)) { $id = $row[id]; $location = $row[location]; $employer = $row[employer]; ... } I'd like to do this for all columns in the table, and feel like there's a way to do this automatically, but haven't been able to find the function or syntax to use. Any help is greatly appreciated. Thanks, Zeth
Re: [PHP-DB] Column names into variables
I believe this does exactly what you want. http://us3.php.net/extract Ben Hatfield Programmer [EMAIL PROTECTED] Soapbox Studio, Inc. 469 N. Lake Street Mundelein, IL 60060 P: +1.847.566.0666 x6# www.soapboxstudio.com On Jul 26, 2006, at 12:14 pm, z wrote: Hi, I have a table with about 50 columns in it. I'd like to query the information for one record, and hold the data in variables that have the same name as the column headings, along these lines: $query = Select * from `postings` where `id` = $userid; $result = mysql_query($query); while($row=mysql_fetch_array($result)) { $id = $row[id]; $location = $row[location]; $employer = $row[employer]; ... } I'd like to do this for all columns in the table, and feel like there's a way to do this automatically, but haven't been able to find the function or syntax to use. Any help is greatly appreciated. Thanks, Zeth -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] column names
HI, does anyone knows how to retrive information about the columns names of a table? I know that is possible to use show table mytable using isql but I need to get information about the columns using sql. that information is to be accessed with a php script. so, I'm looking for something resembling "select info from table" How may I supposed to do that? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] column names
"SHOW FIELDS FROM $table" - Brian Tangible Networks www.tangible-networks.com -Original Message- From: Mauricio Junqueira [mailto:[EMAIL PROTECTED]] Sent: Tuesday, April 03, 2001 5:10 PM To: [EMAIL PROTECTED] Subject: [PHP-DB] column names HI, does anyone knows how to retrive information about the columns names of a table? I know that is possible to use show table mytable using isql but I need to get information about the columns using sql. that information is to be accessed with a php script. so, I'm looking for something resembling "select info from table" How may I supposed to do that? -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] column names
Meir kriheli wrote: On Tuesday 03 April 2001 23:10, Mauricio Junqueira wrote: HI, does anyone knows how to retrive information about the columns names of a table? I know that is possible to use show table mytable using isql but I need to get information about the columns using sql. that information is to be accessed with a php script. so, I'm looking for something resembling "select info from table" How may I supposed to do that? Hi Mauricio, I guess you're using Interbase (isql). The system table your looking for is named RDB$RELATION_FIELDS Your select should be something like: select RDB$FIELD_NAME from RDB$RELATION_FIELDS where RDB$RELATION_NAME = 'your_table_name' I'm building a new system, and I don't have an installation of Interbase I can check this on. I've got it from the Interbase documentation (the LANGREF.pdf file). HTH Thank you so much, It was exactly what I was looking for. I will now give deep look on those system tables. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]