Newbie: need to left align and right align text on a single line

Discussion in 'PHP' started by MarkHoward, Jul 29, 2011.

  1. #1
    Hi, I'm not a programmer but just need a small tip about this.

    I have a code snippet that runs as follows:
    	echo "<div>";
    	echo "<h3 align=left>".sprintf($in_chat)."</h3>";
    	echo "</div>";
    
    Code (markup):
    I wish to add the following to that output line, only aligned right.
    	<a href="http://www.someplace.co.nz" title="cPanel Hosting"><img src="/graphic.png" width="100" height="30 border="0"></a>
    Code (markup):

    Is anyone here able to help me with this?
     
    MarkHoward, Jul 29, 2011 IP
  2. dthoai

    dthoai Member

    Messages:
    106
    Likes Received:
    2
    Best Answers:
    1
    Trophy Points:
    38
    #2
    Instead of using:

    
    echo "<h3 [COLOR="red"]align=left[/COLOR]>".sprintf($in_chat)."</h3>";
    
    Code (markup):
    Try using:

    
    echo "<h3 [COLOR="red"]style='text-align:right'[/COLOR]>".sprintf($in_chat)."</h3>";
    
    Code (markup):
     
    dthoai, Jul 29, 2011 IP
  3. MarkHoward

    MarkHoward Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Sorry, didn't make it clear.
    I want $in_chat aligned left and the href stuff aligned right in the same line.
     
    MarkHoward, Jul 29, 2011 IP
  4. dthoai

    dthoai Member

    Messages:
    106
    Likes Received:
    2
    Best Answers:
    1
    Trophy Points:
    38
    #4
    You can use following codes:

    
    echo "<h3><span[COLOR="red"] style='float:left'[/COLOR]>".sprintf($in_chat)."</span><a [COLOR="red"]style='float:right'[/COLOR] href='http://www.someplace.co.nz' title='cPanel Hosting'><img src='/graphic.png' width='100' height='30' border='0'></a></h3>";
    
    Code (markup):
     
    dthoai, Jul 29, 2011 IP
  5. MarkHoward

    MarkHoward Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Hi dthoai
    Thanks for that very useful suggestion. With your help I have managed to get it sorted, with the following code.
    
                echo "<div>";
                echo "<h3 align=left>".sprintf($in_chat).
    			"<span style='float:right'>
    			Hosted by "." 
    			<a href='http://www.flexihost.co.nz' 
    			title='NZ Hosting from $4.95/month'>
    			<img src='../../../../../images/ads/flexihost.png' width='100' height='15' border='0'> 
    			</span></h3>";
                echo "</div>";
    
    Code (markup):
    I appreciate your help :)
     
    MarkHoward, Jul 30, 2011 IP