Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    Senior Coder
    Join Date
    May 2006
    Posts
    1,680
    Thanks
    28
    Thanked 4 Times in 4 Posts

    How do I add dots to my variable ?

    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.

    PHP Code:
    $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.

    Any ideas ?

    Thanks

  • #2
    Regular Coder
    Join Date
    Nov 2007
    Location
    Leeds, UK
    Posts
    514
    Thanks
    24
    Thanked 19 Times in 19 Posts
    Quote Originally Posted by jeddi View Post
    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.

    PHP Code:
    $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.

    Any ideas ?

    Thanks
    PHP Code:
         $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
    Working towards a Internet where we don't have website just browser applications Kill the Hyper-link and say hello to 3D Games in the browser :)

  • #3
    Regular Coder seco's Avatar
    Join Date
    Nov 2008
    Location
    Oregon
    Posts
    687
    Thanks
    6
    Thanked 79 Times in 77 Posts
    why not just use divs and css?

  • #4
    Regular Coder
    Join Date
    Nov 2007
    Location
    Leeds, UK
    Posts
    514
    Thanks
    24
    Thanked 19 Times in 19 Posts
    yea that works
    Working towards a Internet where we don't have website just browser applications Kill the Hyper-link and say hello to 3D Games in the browser :)

  • #5
    Senior Coder Len Whistler's Avatar
    Join Date
    Jul 2002
    Location
    Vancouver, BC Canada
    Posts
    1,323
    Thanks
    26
    Thanked 100 Times in 100 Posts
    In word processing it's called a Tab Leader, Quark supports the feature. If you Google "php tab leader" you might find a solution.



    ------------
    Leonard Whistler

  • #6
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,994
    Thanks
    4
    Thanked 2,662 Times in 2,631 Posts
    str_pad.
    Won't accommodate for shorter text, but will take care of longer.
    PHP Code:
    $D_Prod_Name 'Example Text';
    $D_Prod_Link 'wherever';
    printf("%s%s\n"str_pad($D_Prod_Name80'.'), $D_Prod_Link); 
    Results:
    Code:
    Example Text....................................................................wherever
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

  • #7
    Senior Coder
    Join Date
    May 2006
    Posts
    1,680
    Thanks
    28
    Thanked 4 Times in 4 Posts
    Thanks for all your help.

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

    This is how I am using it:
    PHP Code:
    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

  • #8
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #9
    Senior Coder
    Join Date
    May 2006
    Posts
    1,680
    Thanks
    28
    Thanked 4 Times in 4 Posts
    Having read the other thread that abduraooft pointed at,
    I think that in this case, a table is warrented,

    so I am using this:

    Code:
    <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:

    Last edited by jeddi; 08-23-2009 at 01:36 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •