Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
Password Reminder
Register
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
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
Reply With Quote
  #2 (permalink)  
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
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 Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 12:43 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.