If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Formatting sql output

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-10-08, 13:53
pgb205 pgb205 is offline
Registered User
 
Join Date: Nov 2008
Posts: 2
Formatting sql output

let's say i do

select field1from table;
and output is

data1 value
data2 value

I want to display this on a webpage but don't want to run another script to format this in php. Can I tell mysql to insert the php tags into the output. So basically when running above command in batch mode have mysql output be output into .php file containig something like

<?php
data1 value
data2 value
/php>

So basically tell select sql to append certain text in certain locations to the output.
How can this be done.
Reply With Quote
  #2 (permalink)  
Old 12-10-08, 14:37
healdem healdem is online now
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,262
don't even think of going there

the best option may be to get MySQL to output XML tags, if your version doesn't then you could output the tags as
select "<ROW><COL1>".Column1."</COL1>" as expression1, .......<COLn>".Column1."</COLn></ROW>" as expressionn from my table

its reasonably trivial to dump data from MySQL into say a table in PHP so I'd suggest you do it that way
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
  #3 (permalink)  
Old 12-17-08, 07:01
samrawet samrawet is offline
Registered User
 
Join Date: Nov 2008
Posts: 4
<?php
echo "data";
<?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On