473,405 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

padding with spaces

I am trying to pad a number with spaces to the left. I can pad it with
zeros as in this code:

printf("<option value='%d'>%04s %s</option>n",
$row->id,
$row->NumberOfQuotes,
arrangeName($row->lastName, $row->firstName, $row->middleName,
$row->Title, $row->suffix));

Trying to do the same with spaces. It is not padding all the spaces but
only one space. Right justification:

printf("<option value='%d'>%4s %s</option>n",
$row->id,
$row->NumberOfQuotes,
arrangeName($row->lastName, $row->firstName, $row->middleName,
$row->Title, $row->suffix));

Even with left justification:

printf("<option value='%d'>%-4s %s</option>n",
$row->id,
$row->NumberOfQuotes,
arrangeName($row->lastName, $row->firstName, $row->middleName,
$row->Title, $row->suffix));

Does Anyone have any ideas on what I am doing wrong?

--
Thanks in Advance... http://ichbin.9999mb.com
IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
__________________________________________________ ____________________
'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
Nov 28 '06 #1
3 2052
IchBin wrote:
I am trying to pad a number with spaces to the left. I can pad it with
zeros as in this code:

printf("<option value='%d'>%04s %s</option>n",
$row->id,
$row->NumberOfQuotes,
arrangeName($row->lastName, $row->firstName, $row->middleName,
$row->Title, $row->suffix));

Trying to do the same with spaces. It is not padding all the spaces but
only one space. Right justification:

printf("<option value='%d'>%4s %s</option>n",
$row->id,
$row->NumberOfQuotes,
arrangeName($row->lastName, $row->firstName, $row->middleName,
$row->Title, $row->suffix));

Even with left justification:

printf("<option value='%d'>%-4s %s</option>n",
$row->id,
$row->NumberOfQuotes,
arrangeName($row->lastName, $row->firstName, $row->middleName,
$row->Title, $row->suffix));

Does Anyone have any ideas on what I am doing wrong?
This is an HTML question, not a PHP question.

HTML compresses multiple blanks into a single one. To have a
non-breaking space you need to use &nbsp;

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Nov 28 '06 #2
On Tue, 28 Nov 2006 15:51:44 -0500, in comp.lang.php IchBin
<we******@ptd.net>
<RN********************@ptd.netwrote:
>| I am trying to pad a number with spaces to the left. I can pad it with
| zeros as in this code:
|
| printf("<option value='%d'>%04s %s</option>n",
| $row->id,
| $row->NumberOfQuotes,
| arrangeName($row->lastName, $row->firstName, $row->middleName,
| $row->Title, $row->suffix));
|
| Trying to do the same with spaces. It is not padding all the spaces but
| only one space. Right justification:
|
| printf("<option value='%d'>%4s %s</option>n",
| $row->id,
| $row->NumberOfQuotes,
| arrangeName($row->lastName, $row->firstName, $row->middleName,
| $row->Title, $row->suffix));
|
| Even with left justification:
|
| printf("<option value='%d'>%-4s %s</option>n",
| $row->id,
| $row->NumberOfQuotes,
| arrangeName($row->lastName, $row->firstName, $row->middleName,
| $row->Title, $row->suffix));
|
| Does Anyone have any ideas on what I am doing wrong?
The web browser automatically removes multiple spaces.
You will need to use &nbsp; for the spaces to be displayed.
---------------------------------------------------------------
jn******@yourpantsyahoo.com.au : Remove your pants to reply
---------------------------------------------------------------
Nov 28 '06 #3
Jerry Stuckle wrote:
IchBin wrote:
>I am trying to pad a number with spaces to the left. I can pad it with
zeros as in this code:

printf("<option value='%d'>%04s %s</option>n",
$row->id,
$row->NumberOfQuotes,
arrangeName($row->lastName, $row->firstName, $row->middleName,
$row->Title, $row->suffix));

Trying to do the same with spaces. It is not padding all the spaces
but only one space. Right justification:

printf("<option value='%d'>%4s %s</option>n",
$row->id,
$row->NumberOfQuotes,
arrangeName($row->lastName, $row->firstName, $row->middleName,
$row->Title, $row->suffix));

Even with left justification:

printf("<option value='%d'>%-4s %s</option>n",
$row->id,
$row->NumberOfQuotes,
arrangeName($row->lastName, $row->firstName, $row->middleName,
$row->Title, $row->suffix));

Does Anyone have any ideas on what I am doing wrong?

This is an HTML question, not a PHP question.

HTML compresses multiple blanks into a single one. To have a
non-breaking space you need to use &nbsp;
Sorry, I did not think before I posted to this newsgroup..

--
Thanks in Advance... http://ichbin.9999mb.com
IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
__________________________________________________ ____________________
'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
Nov 28 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Prithpal | last post by:
Please help!!! We had a sql server 7 DB, with a char 8 field, in which some of the data was only 7 characters in length. Via a type 4 JDBC driver, we got back a NON space padded String. This...
0
by: Andreas Emmert | last post by:
Hi NG, I have a submit button on my form with the class "button", i.e. <input type=button class=button value=XXXX> The class is currently defined as ..button {
2
by: John Bowman | last post by:
Hello, I need to concatonate 2 strings and insert padding spaces in between them. The number of padding spaces needs to be calculated such that I can place the entire resultant string into a...
7
by: Astra | last post by:
Hi All Can you please help me with a few queries on adding a header line and padding rows out. I apologise profusely for not providing the DDL for this, but I don't have it. All I have is...
2
by: JohnR | last post by:
When creating an msAccess db within the Access UI itself the fields that are text are NOT padded with blanks. For example, if I have a 10 char field and put in "HI" and then when I come back to...
13
by: lossed | last post by:
Hi everyone, Please excuse me if this has been asked before or sounds a bit dim. This is a question asked on another forum but the solutions being offered are focussing on programming rather...
3
by: dchristjohn | last post by:
I am currently developing a small windows application using Visual Basic via Visual Studio 2005. My database resides on a SQL 2000 server. I have a table with three fields: id (int, Not Null)...
1
by: MaRkHaSBEEnMade | last post by:
Hi there I currently have a listbox that displays provinces,regions and suburbs.I want to pad the items logically with spaces,but the spaces are being igonred... eg Province1 ...
14
by: Richard Maher | last post by:
Hi, Can anyone please show me a regular expression (or function or other) for padding out a string to a fixed number of bytes? At the moment I've got a var initialized to N spaces, where 'N'...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.