Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Does anybody know of a format mysql query function out there?

Status
Not open for further replies.

justride

Programmer
Jan 9, 2004
251
US
Does anybody know if there is a function to take a query string and format it nicely to display on a web page in a print statement or text area or soemthing?

Soemthign like you see in phpmyadmin, or perhaps somebody has the function used in phpmyadmin?

I want to display queries to users but they look right crap now, and before I wrote a fucntion I wanted to ask around.

Thanks
 
I haven't seen one.

If you do, would you mind if I saw it?

-Kerry
 
I just looked at phpmadmin briefly, crazy code, I havent figured out how they do it.

Anyone else?
 
it's a function called PMA_SQP_formatHtml in sqlparser.lib.php in the libraries directory. i have not fully examined the code but i suspect that it can be used statically. the text below is taken from the comment block in this library

* If you want a pretty-printed version of the query, do:
* $string = PMA_SQP_formatHtml($parsed_sql);
* (note that that you need to have syntax.css.php included somehow in your
* page for it to work, I recommend '<link rel="stylesheet" type="text/css"
* href="syntax.css.php" />' at the moment.)

don't forget to attribute phpmyadmin if you use their code. there may also be licence restrictions on using part rather than all.
 
Thanks for the function, I will look into it. Thanks for the advice.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top