Displaying Column Names
Posted on
16th Feb 2014 07:03 pm by
admin
I have a question regarding the ability to show the column names from my table/query.
What I'm looking to do is to be able to have my users enter their own query via a builder (Which I haven't built yet).
I've found a little test script from the net but it shows them in an array.
Did you know?Explore Trending and Topic pages for more stories like this.
My code is
Code: [Select]<?php
include('includes/inc.conn.php');
mysql_select_db("discover_messaging");
$result = mysql_query("SHOW COLUMNS FROM `messages`");
if (mysql_num_rows($result) > 0) {
while ($row = mysql_fetch_assoc($result)) {
print_r($row);
}
}
?>
Which outputs
QuoteArray ( [Field] => msg_id [Type] => int(11) [Null] => NO [Key] => PRI [Default] => [Extra] => auto_increment ) Array ( [Field] => msg_to [Type] => varchar(99) [Null] => NO [Key] => [Default] => [Extra] => ) Array ( [Field] => msg_from [Type] => varchar(99) [Null] => NO [Key] => [Default] => [Extra] => ) Array ( [Field] => msg_subject [Type] => varchar(255) [Null] => NO [Key] => [Default] => [Extra] => ) Array ( [Field] => msg_body [Type] => text [Null] => NO [Key] => [Default] => [Extra] => ) Array ( [Field] => read_flg [Type] => varchar(3) [Null] => NO [Key] => [Default] => off [Extra] => ) Array ( [Field] => sent_date [Type] => varchar(255) [Null] => NO [Key] => [Default] => [Extra] => )
Is there a way to have the field names come out of the array so that I can do something like?
Code: [Select]<table>
<tr>
<td>msg_id</td>
<td>msg_to</td>
etc ...
Thanks all.
No comments posted yet
Your Answer:
Login to answer
337
38
Other forums
RTF fomatting to email content
Im trying to sen an email with content is picked up from a rtf-file (file_get_contents('*.rtf'). Mai
Delete Client 066 Earlywatch
Hi all,
in former times client earlywatch was required for SAPs remote access to SAP inst
Getting Subdomain Name With PHP?
I want to grab the subdomain name with PHP so I can generate database queries.
for example my
PHP Include w/If IE Condition Statement?
I was having a problem with Internet Exploder (big surprise, right?) displaying my drop down menus i
INSERT for date range
Hi all
I have the following table
Code: [Select] `date` date
`day` int(2)
`
my login script page is not working on remote computers
hi my login is working on my computer, but when i tried 2 computers from 2 different locations, they
Help with Contact Form
I have this Form on an html page and the associated code on page.php (below).
I keep getting the
Regular expression tips or resources
Hello! I'm having some issues implementing the appropriate regex patter to eliminate unwanted charac
Page doesn't expand for content
Hi. I've been testing a query I made. It's here http://lapr1.6te.net/inquerito.php
The page doesn
Implementing Single Sign-On using SAML 1.1, x.509, LDAP in C#.net
Hi,
I got a requirement from the client i.e implementing single sing on using SAML 1.1( LDAP &