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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing Address Labels 2

Status
Not open for further replies.

pastorandy

IS-IT--Management
Nov 2, 2006
84
0
0
GB
I have a mySQL DB with customer details and I would like to be able to generate a query to print out address labels.

How would I write the query so that it prints out to the screen in a format that is two labels across and 4 rows down? A total of 8 labels on each page but further pages if the dataset is greater than 8 customers.

Any ideas?
 
Hi Andy

that's the heredoc syntax. I find it useful when outputting blocks of html or text in which i want to preserve quotation marks. it is undoubtedly slower in execution than using single quotes and concatenation, but similar in speed to the use of double quotes.

to include arrays within the heredoc you need to use curly braces. unfortunately you cannot easily stop and start the syntax to use functions. or rather you can ... but it looks confusing:

Code:
function test(){
 return "black";
}
echo <<<EOL
  The Colour that is was talking about was
EOL
. test();

you start the heredoc with <<< and follow the chevrons with some identifier. The content starts after the first space and continues until ended. You end the syntax by repeating the identifier hard up against the left margin. you can terminate the line with a semicolon or, if you want to concatenate, start with the dot operator on the next line.

the nice thing about heredoc is it also preserves the source formatting. Take a look at the source code of the outputted labels and you will see it looks better than it might for generated content.

There is lots more on the various available syntaxes in the online manual.

cheers
Justin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top