473,785 Members | 2,777 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Maintain spacing when concatenating

1 New Member
I'm trying to concatenate a half dozen fields from an sql statement into a string, then loading the string in a select list. I can't seem to find a way to keep them 'lined up' - so if, for instance, I concatenate a name field and address field, I want the first letter of the first names to line up, and the first letter of the addresses to line up in my list box. I've been trying str_pad(), but can't get that to work for some reason - If I pad with a character, I get the characters in the result, but if I pad with blanks, I lose the blanks. Don't get it.
Nov 1 '08 #1
2 1606
dlite922
1,584 Recognized Expert Top Contributor
I'm not sure what you been by concatenating in a select list (I'm assuming you mean a HTML select box)

HTML ignores spaces. For output you can use the <pre></pre> tags and that will display the text just as you type it into the code, spaces and all.

From what it sounds like you're having a HTML issue, and its not related to PHP.





Dan
Nov 1 '08 #2
Atli
5,058 Recognized Expert Expert
We would have to see the actual code to be able to say for sure, but I think Dan got it right. HTML does not preserve white-spaces, such as spaces and newlines.

If you need to add a series of spaces into your HTML you have three options:
  • The easiest solution would be to use the &nbsp; entity. It represents a single space.
  • Second, as Dan suggested, the <pre> tag preserves any white-spaces that occur within it.
  • Or, if you use CSS, you can apply the "white-space: pre" style to the element containing your data. That would preserve the white-spaces, just like a <pre> tag would.
Nov 1 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
3462
by: Hal Vaughan | last post by:
I'm testing a GUI app on a couple Linux boxen and one Win2k box. I'm using Java 1.4.2 on each (or the closest on Win2k -- whatever version comes close). On one Linux box and the Win2k box the line spacing is very close (for example, when I use HTML in JLabels, or even in JTextAreas), but on the other Linux box, the line spacing is much wider. I'm using default Swing fonts -- I'm not setting anything. I can't find a field or function...
7
7116
by: Danny | last post by:
I have a small <div> element which contains two text blocks - one within <h5> tags and the other within <p> tags. I don't want any extra line spacing between elements so use the display:inline property. This works for IE6 but Opera7.54 and Netscape7.1 add large line spacing between the text blocks and any lines of wrapped text. The line spacing is independant of the font size and is consistent between all lines. ie: it's not larger...
4
3564
by: fleemo17 | last post by:
Is there a way to tweak the spacing of lines of text (or leading) *specifically* in IE6? I've created a "Quick Search" box in my layout which renders pretty consistently in all the browsers I've tested it on, except in IE6 for the PC. The spacing is completely inconsistent with all the other browsers. (See http://www.sunriveronline.org/misc/clrn ) Is there a way to include a few lines of code in my CSS file that will adjust IE6's...
4
2350
by: Juan | last post by:
Does any one know if there are reported bugs when concatenating strings? When debugging each variable has the correct value but when I try to concatenate them some values are missing (I can´t see them in the debugger). After encoding the string (the sameone which complete value is not visible from the debugger) all the values can be seen but they are spaced by big amounts of zeros and use more that the 2048 bytes allocated. It is like if...
7
2104
by: Mike P | last post by:
I read somewhere that if you are concatenating more than 2 or 3 strings you should use StringBuilder as it will use up less resources. Does this apply when you are building up a string (for example an SQL query or some XML)? This is an example of some of my current code : strReturnedXML = "<?xml version=\"1.0\"?>"; strReturnedXML += "<vcn-rsp message-id=\"" + Convert.ToString(bytMessageID) + "\">";
5
1437
by: John Smith | last post by:
Here is my HTML table formatting code. <table border="1" width="100%"> <tr width = "100%"> <td width="33%">11asdhagdshaskgashjgahjgadhjgdjshdgasjdgajdgadjhgdgahjdgadhjsgad
4
2470
by: metoikos | last post by:
I've scoured the web (clumsily, I'm sure) for information on the difficulties I am having, checked my markup in validators, and had a friend with more CSS clue look over it, but I haven't had any luck. I'll detail my difficulties here and hope for help. I will note that I'm using headings to delineate different sections of my message for easier reading. As you can see from the subject, my problems are related to spacing; one of them is...
10
11056
by: phil-news-nospam | last post by:
I have a table with 3 columns in 1 row. I want to increase the spacing _between_ the columns (gutter) _without_ increasing the spacing between those columns and the table itself. Is there a way to do that in CSS without having to code in extra dummy columns in HTML to create gutters? -- ----------------------------------------------------------------------------- | Phil Howard KA9WGN | http://linuxhomepage.com/ ...
5
5805
by: Memphis Steve | last post by:
Is is possible to control spacing between two lines when using <br />? I would like to be able to adjust the spacing between the two lines in each link below so that the two lines sit snugly on top of each other within each anchor without a lot of extra space between each line. I am self taught in XHTML and CSS and would appreciate any suggestions? THE XHTML: <ul id="ns-buttons-links"> <li id="nsbl-request"><a href="#"><span...
4
2208
by: Mamluk Caliph | last post by:
For quite some time I've used code as the following to be able to "cut&paste" parts from different headerfiles of the same name. It has worked with GCC, MS, Borland, Keil to name a few. In principle the mechanism looks like this: #define CHAINPATH /usr/include #define DEFSTR( x ) \ #x
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10327
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10151
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10092
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9950
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8973
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2879
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.