Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 07-04-2004, 08:55 PM String Pad Help
Novice Talker

Posts: 9
Trades: 0
Does anyone have any ideas on why this won't work? I'm pulling a variables from the DB and I want to display them in a list evenly spaced out. But the str_pad function does not seem to be working so I must be doing something wrong:

PHP Code:
    // Display member list for private message selection
    
while ($row_add mysql_fetch_array($result_add))
    {   
        echo (
'<option value="'.$row_add['user_id'].'">'.str_pad($row_add['username'],35).' | '.str_pad($row_add['storename'], 25).' | '.str_pad($row_add['companyname'], 25).'</option>');
    } 
mattmcb is offline
Reply With Quote
View Public Profile Visit mattmcb's homepage!
 
 
Register now for full access!
Old 07-04-2004, 09:26 PM
Kyrnt's Avatar
The Post-Mod Years

Posts: 2,536
Location: Western Maryland
Trades: 0
matt,

The problem is not with PHP, but with your browser and HTML in general. The spaces are there, but remember that browsers ignore extra spaces and line feeds and are doing so here.

Try this code:

PHP Code:
echo ('<option value="' .$row_add['user_id'].'">' 
       
padWithHTMLSpaces($row_add['username'],35). ' | ' 
       
padWithHTMLSpaces($row_add['storename'], 25). ' | ' 
       
padWithHTMLSpaces($row_add['companyname'], 25
       . 
'</option>'); 


// You'll need this little function
function padWithHTMLSpaces$szin$targetLength )
{
    
$szout str_pad$szin$targetLength" "STRING_PAD_RIGHT );
    return 
str_replace" ""&nbsp;"$szout );

Hope this helps.
__________________
—Kyrnt
Kyrnt is offline
Reply With Quote
View Public Profile Visit Kyrnt's homepage!
 
Reply     « Reply to String Pad Help
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.09724 seconds with 12 queries