Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
| Search | Today's Posts | Mark Forums Read
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 12th, 2004, 06:15 AM
Registered User
 
Join Date: May 2004
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to yourcompadre
Default MYSQL Query text Formatting

Hi,

I need help with the format of query results. I get the correct results but when it outputs to a file the format is terrible. What I hope someone can help me with is setting the columns to a smaller size so that the headers are closer to there columns.

Thanks in advance,
Kevin
 
Old May 12th, 2004, 06:55 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , United Kingdom.
Posts: 256
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It depends entirely on how you are outputting them. If output as part of your HTML output, it won't matter, since HTML ignores whitespace, such as newlines, when displayed by a web browser. So, if you're outputting them in an HTML table, say, just make the coumn wider: it won't matter what the raw HTML looks like, as far as the browser is concerned.

If you are producing an XML document, or suchlike, you'll have to reformat the text as delivered from the database, removing newlines wth something like:

$textfield=str_replace(chr(13), "", $text field);

..a.nd then:

$textfield = chunk_split($textfield, {chunklength}, {endcaharcter})

Where chunklength, is the number of columns, per line, you'd prefer, and endcharacter, is the end-of-line character youw ant to insert, such as the carriage return/linefeed combination for Windows machien s (i.e. "\r\n").

Either way, the text in each text-type field is part of the text, newlines, tab-characters, and all, so reformatting it is the job of PHP extraordinarily extensive array of string-manipulation functions.

HTH
Dan




Similar Threads
Thread Thread Starter Forum Replies Last Post
formatting dates back to Mysql date format melkin Classic ASP Professional 1 February 19th, 2008 01:58 PM
Formatting Query rsm42 ASP.NET 1.0 and 1.1 Basics 1 May 19th, 2007 04:58 AM
Formatting a text box alantodd Access VBA 3 December 14th, 2004 05:59 PM
text formatting question dadoonan BOOK: Beginning ASP 3.0 1 November 15th, 2004 02:12 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.