...

View Full Version : How do I add dots to my variable ?



jeddi
08-22-2009, 06:43 PM
Here is an interesting one!

I would like to add dots to the end of my variable so that
it the eye can line it up with a link.

Like this:


Some text ........................ the link
example ........................... another link
and one more ................... link

as you can see, the number of dots will differ according to the
length of the variable.

I have written this so far, but I don't know how to
add the dots.


$num_dots = 80-strlen($D_prod_name);
$D_prod_name = $D_prod_name.$num_dots ( write that number of dots ??? )


Of course maybe I should be doing this with
a css style property, but I can not find one that
does it.:confused:

Any ideas ?

Thanks:)

barkermn01
08-22-2009, 06:49 PM
Here is an interesting one!

I would like to add dots to the end of my variable so that
it the eye can line it up with a link.

Like this:


Some text ........................ the link
example ........................... another link
and one more ................... link

as you can see, the number of dots will differ according to the
length of the variable.

I have written this so far, but I don't know how to
add the dots.



$num_dots = 80-strlen($D_prod_name);
$D_prod_name = $D_prod_name.$num_dots ( write that number of dots ??? )


Of course maybe I should be doing this with
a css style property, but I can not find one that
does it.:confused:

Any ideas ?

Thanks:)


$num_dots = 80-strlen($D_prod_name);
$D_prod_name = $D_prod_name.$num_dots;


I think you trying to do but i dont think this will work how you want,
As
a is bigger then i in width so they still wont line up
The best thing todo is add a TAB but im not sure what the quote char is for a tab you could try " " - thats supposed to be a TAB in the quotes lol

seco
08-22-2009, 07:02 PM
why not just use divs and css?

barkermn01
08-22-2009, 07:04 PM
yea that works

Len Whistler
08-22-2009, 10:05 PM
In word processing it's called a Tab Leader, Quark supports the feature. If you Google "php tab leader" you might find a solution.



------------

Fou-Lu
08-22-2009, 11:32 PM
str_pad (http://php.ca/manual/en/function.str-pad.php).
Won't accommodate for shorter text, but will take care of longer.


$D_Prod_Name = 'Example Text';
$D_Prod_Link = 'wherever';
printf("%s%s\n", str_pad($D_Prod_Name, 80, '.'), $D_Prod_Link);

Results:


Example Text....................................................................wherever

jeddi
08-23-2009, 01:42 PM
Thanks for all your help.

This works:
$D_prod_name = str_pad($D_prod_name, 80, '.'); :thumbsup:

This is how I am using it:

echo "<br> $D_prod_name <a href=\"edit_prods.php?id={$row_prod['prod_id']}\">Edit</a>";


But because of this:

As a is bigger then i in width so they still wont line up

It won't line up very well.
I think I need to out in a couple of divs or spans,
one with align:left and the other with align:right.

Is that the best way ?
I am trying to stay away from using a table.

Any ideas about how to best display this into a 200px wide space ?

Thanks

abduraooft
08-23-2009, 01:51 PM
http://www.codingforums.com/showthread.php?t=108909 might be useful.

jeddi
08-23-2009, 02:31 PM
Having read the other thread that abduraooft pointed at,
I think that in this case, a table is warrented,

so I am using this:



<p>
<table summary="">
<tr style="font-weight:bold;"><td>Your Products</td><td></td><td></td></tr>

<?php
$sql_prod = "SELECT * FROM products WHERE owner_id = '{$_SESSION['member']}' ";
$result_prod = mysql_query($sql_prod) or die("could not execute FIND MEMBER query.". mysql_error());
if(mysql_num_rows($result_prod) == 0 ){
echo "<tr><td width = \"140px\">You have no products recorded!<td></td><td></td></tr>";
} // end if
else {
while ($row_prod = mysql_fetch_assoc($result_prod)) {
$D_prod_name = "{$row_prod['prod_name']}";
echo "<tr><td width = \"140px\">$D_prod_name</td><td style=\"text-align:center; \">...........................................................</td><td style=\"text-align:left; width:50px;\"><a href=\"edit_prods.php?id={$row_prod['prod_id']}\">Edit</a></td></tr>";
} // end while
} // end else
echo "</table><br><b>End of report.</b>";?>
</p>

Should I put an overall width on the table ?
- or on the row ?

The result looks like this:

http://www.expert-world.com/sp/problem2.jpg



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum