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
My XSRF Prevention code isn't working
First of all, thanks for the generous help you guys have given me in the past on this forum.
Seco
Points for Wiki contribution
Hi everyone,
I want to know how long does it take for the moderator to award points for a
Help uploading .JPG
I have a problem with upload images when the ending is .JPG capitalized.. I really don't know what c
How to disable direct access to a file
Suppose I've 2 Files. 1.php & 2.php
I don't want anybody to access 2.php directly fr
$variable $variables type question
I need to be able to designate an array element dynamically, so I thought to use a variable variable
Inserting the current date/time while submitting the forum
What do I need to add below to update the current date/time? I have a field in the database called d
Help, Base64 encoding url and decoding server side.
Hello everyone, i have a website with videos and games and also provide an embed code which people c
Post PHP form to non-existing page
The company that I work for host their PHP code on IIS on a Windows server, no Apache, so no mod_rew
Scheduler problems related to execution of a single BLT by many schedules
Hello all,
We are running several MII instances in a distibuted architecture using a sing
FROM_UNIXTIME($phpdate);
Hello,
I tried to use this :
$date = FROM_UNIXTIME($phpdate);
ANd I was t