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.
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
If statement help please.
Hello on my site I have 2 content boxes. 1 is for the main content (which is the biggest one) and th
Creating a custom API
I'm creating a site, and I need to create a basic API. Unfortunately I have no idea where to start.
Taylor Series Function
So I am working a a project for my intro C++ class, and I am having some trouble with a function for
What are the two different files you download to update kernel?
What are the two different files you download to update kernel?
Storing Values taken from a DB...
Using this code it will generate a short list from my database
<?php
mysql_connect
Is it possible to stop reservation creation in PM Order?
Hi All,
Is it possible to stop reservation creation in PM Order?
Thanks in adv
Create a form of 2 numbers input and find the greatest.
Hi, everybody.
I have a homework in my training of php, which ask you to make a form that ask
Impact of movement type 412 E on MAP
Hi
Usage of movement type 412 E is causing huge change in MAP .
Is there any r
Problem with PHP/mySQL login code
Hello,
There is an error in my login script and I can't figure out what it is...
I believe
New Search Engine
Hey everyone,
I have a ZIP Code Radius search engine already functional. it displays all of t