473,396 Members | 1,767 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,396 software developers and data experts.

Getting PHP variables to display fixed length

Hello,
I am coding a menu using PHP. Selections on the menu have code like :

<li> <a href="Updatefindatesedit.php">$fin_name1 $fin_date1 </a></li>
<li> <a href="Updatefindatesedit.php">$fin_name2 $fin_date2 </a></li>
etc
My problem is the $fin_name1 variables can be anywhere from 1 - 20
characters

so my menu items come out looking like
Joe 2000/01/01
Fred 2001/01/02
Alexander 2001/01/03

Can I get the $fin_name* variable to take up a fixed amount of space
when displaying? My idea is to use strlen on fin_name and put a number
of &nbsp's between, but that sure seems like a dumb way to do it. I
figure someone with more knowledge can tell me an easier way to do
it....
TIA
Japhy

Oct 29 '05 #1
6 2608
On 28 Oct 2005 20:00:11 -0700, in comp.lang.php "Japhy"
<ja************@yahoo.com> wrote:
| Hello,
| I am coding a menu using PHP. Selections on the menu have code like :
|
| <li> <a href="Updatefindatesedit.php">$fin_name1 $fin_date1 </a></li>
| <li> <a href="Updatefindatesedit.php">$fin_name2 $fin_date2 </a></li>
| etc
|
|
| My problem is the $fin_name1 variables can be anywhere from 1 - 20
| characters
|
| so my menu items come out looking like
| Joe 2000/01/01
| Fred 2001/01/02
| Alexander 2001/01/03
|
| Can I get the $fin_name* variable to take up a fixed amount of space
| when displaying? My idea is to use strlen on fin_name and put a number
| of &nbsp's between, but that sure seems like a dumb way to do it. I
| figure someone with more knowledge can tell me an easier way to do
| it....


You might have to re-think the layout. HTML will automatically remove
extraneous spaces. You will need to use &nbsp; for padding.

Also, you will need to use a fixed width font i.e. monospace.
<li style="font-family: monospace"> <a
href="Updatefindatesedit.php">$fin_name1 $fin_date1 </a></li>

Alternatively, use a table for the layout.
---------------------------------------------------------------
jn******@yourpantsyahoo.com.au : Remove your pants to reply
---------------------------------------------------------------
Oct 29 '05 #3
What do you want to do?
* Stretch the text (probably not a good idea)
* Left justify the name and right justify the date? (A table is
probably easiest)
* Have the whole width clickable (set the width of the <a> and have a
background colour which makes this obvious)

Ian

Oct 29 '05 #4
VS
Japhy wrote:
<li> <a href="Updatefindatesedit.php">$fin_name1 $fin_date1 </a></li>
<li> <a href="Updatefindatesedit.php">$fin_name2 $fin_date2 </a></li>
etc
My problem is the $fin_name1 variables can be anywhere from 1 - 20
characters

so my menu items come out looking like
Joe 2000/01/01
Fred 2001/01/02
Alexander 2001/01/03


Why not use a table ??

--
VS
Oct 29 '05 #5
Japhy wrote:
Hello,
I am coding a menu using PHP. Selections on the menu have code like :

<li> <a href="Updatefindatesedit.php">$fin_name1 $fin_date1 </a></li>
<li> <a href="Updatefindatesedit.php">$fin_name2 $fin_date2 </a></li>
etc
My problem is the $fin_name1 variables can be anywhere from 1 - 20
characters

so my menu items come out looking like
Joe 2000/01/01
Fred 2001/01/02
Alexander 2001/01/03

Can I get the $fin_name* variable to take up a fixed amount of space
when displaying? My idea is to use strlen on fin_name and put a number
of &nbsp's between, but that sure seems like a dumb way to do it. I
figure someone with more knowledge can tell me an easier way to do
it....
TIA
Japhy

Can I suggest that the date needs to be moved to a known position to the
right of the name and that sufficient space be provided for the longest
name. An html table is one way. The other is CSS, eg,
<ul>

<li style="width:12em;">
<div style="float:right;width:4px;text-align:right;">yyyy/mm/dd</div>
fin_name
</li>
<li style="width:12em;">
<div style="float:right;width:4px;text-align:right;">yyyy/mm/dd</div>
fin_longer-name</li>

</ul>

adjust the width of the containing div and the float div to suit.

Ideally the css declarations will be in selectors in a style block or
style sheet, e.g.

<style type="text/css">
ul.name-date li { width:12em; }
ul.name-date li div { float:right;width:4px;text-align:right; }
</style>

</head>

<body>

<ul class="name-date">

<li>
<div>yyyy/mm/dd</div>
fin_name
</li>
<li>
<div>yyyy/mm/dd</div>
fin_longer-name</li>

</ul>

Louise
Oct 29 '05 #6
Thanks to all who replied. You've given me a lot of options to
explore.
As for using a table, I got the idea for the menu at Dynamic Drive, and
didn't want to mess
with the 'design' too much.
Thanks again to all!

Oct 29 '05 #7

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

Similar topics

2
by: | last post by:
Information is entered randomly in just one text box (name, social security number, lenght,weight). The problem is how to recognize that what actually was the name, and what was lenght etc. ...
10
by: Stefanie | last post by:
Hi, I have a question about declaring variables for writing data to a file for random access. I have two string variables declared in a module (user-defined types). The point is that for one of...
17
by: Arnold | last post by:
Is using fseek and ftell a reliable method of getting the file size on a binary file? I thought I remember reading somewhere it wasn't... If not what would be the "right" and portable method to...
2
by: Steve Bottoms | last post by:
Hi, all! Using VB as code-behind in asp.net page... I have a TABLE control which I'm building dynamically. After the table is built, I'm trying to retrieve the HEIGHT property of that table...
28
by: Stefan Mueller | last post by:
I can display the value of the following input box with alert(parent.MyFrame.document.MyForm.MyInput.value); But if the frame, the form or the input box doesn't exist I get of course an error...
12
by: libsfan01 | last post by:
hi all i know this isnt the right place to post a css thing but i dont know any other good forums to post to. what im trying to do is get a paragraph tag to display like a textbox but put...
2
by: Frank Swarbrick | last post by:
I'm just learning about embedded SQL, so be gentle... My basic question is, if I use a fixed length host variable for a column defined as VARCHAR, will trailing spaces be removed (or not) upon...
7
by: misha | last post by:
Hello. I was wandering if someone could explain to me (or point to some manual) the process of mapping the addresses of host variables by DB2. Especially I would like to know when DB2 decides to...
3
by: npm | last post by:
Hi, I have javascripts that display the number of radio stations from my xml files. I'm in need of a javascript that can add all the variables and then display the grand total. I looked on...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
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...

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.