Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to right align

Status
Not open for further replies.

newphpbie

Programmer
Joined
Oct 17, 2003
Messages
110
Location
GB
Hi,

I am trying to align some text and buttons on the right side of my page. When I put the align tag in normal html format it works fine but if I echo it in PHP script the align doesn't work.

Just to make sure it's not me doing something silly....this is my code

Code:
echo '<p align=&quot;right&quot;> This should be on the right </p>';

and it still aligns on the left....

If I use a <center> tag, it works fine.....

If I take the line outta PHP script it works fine...

So what is it about PHP that it won't let me Right align???

The only way I can see around this problem is to break my PHP script, add a line of html then start the <?php again....

Surley there is another way....

TIA
 
And is there a benifit to having your html code echoed within the PHP script rather than out of the script?
 
newphpbie:
I've found the benefit to be easier debugging. Context-switching fragments everything. Every script I write has exactly on &quot;<?php&quot; tag on the first line of the script, and exactly one &quot;?>&quot; tag on the last line of the script.


If you view source on the output, does it look right?

Want the best answers? Ask the best questions: TANSTAAFL!!
 
For some reason it won't let me view the source.... My right click works but when I click on View Source nothing happens...

This hasn't occured before....
 
That could be lots of things.

And without examination of the output, it's difficult to know what might be wrong.

You could, I suppose, follow the directions in section 2.6 of my FAQ on debugging PHP to use telnet to view the page. faq434-2999

Want the best answers? Ask the best questions: TANSTAAFL!!
 
Are you working on your own machine, or a hosted server?

Because if you can't view your source you can just do a (on windows, though linux should be really close)
Code:
php myscript.php >> source.html

and you'll have plain html to look at. If it's a hosted server, perhaps Sleipnir would be kind enough to remind us how you can get the same response from teh command line, I know he helped me do it once before... basically making an HTTP request and using the terminal for the output

But thing is, when it's all said and done, php outputs HTML to your page, so it has to be a problem with the source being outputted. (Or your browser)

-Rob
 
Code:
telnet <server ip> 80<enter>

... connected stuff ...

Code:
get / http/1.0<enter><enter>

Or if it's on a box with multiple domains hosted, do:

Code:
get / http/1.1<enter>
host: <your hostname><enter><enter>

Gotta page through it using your telnet client, so use something with a scrollback buffer.

If you are just looking for superficial information and not verbose HTML output, change 'get' to 'head'. It will give timestamp information, filesize, but no content.

----
JBR
 
ok, after re-starting my PC I can now view the source, well I could, but I can't again now.

I could see the correct <p align=&quot;Right&quot;> but it's still not processed..

I'm still boggled why it would work for <center> and not for <right> ????

And without closing my php script and writing the code in striaght HTML I can't get anything on the right hand side of the screen!!!!!

Could someone give me an example of a bit of text aligned right (and within php script) something different to this....
Code:
echo '<p align=&quot;right&quot;> This should be on the right </p>';
cuz I know that doesn't work.

I'm using PHP 4.2 and trying to view the page on IE6. If it helps..
 
Dumb ass....

The line of code I was trying to use was this....
Code:
echo '<p align=right><h2>This should be on the right</h2></p>';

can anyone see what's wrong with this??? Why it wasn't aligning to the right!!??

Do you need a clue???
 
I didn't realise you couldn't right align a heading!!
 
Heading tags should really exist outside the <p> tags as they are effectively blocks of text (<p> tags) with special style attributes.
You can right align a heading by using
Code:
<h2 align=&quot;right&quot;>Right aligned heading</h2>

Better still use CSS to define style rules for your standard HTML tags. This will also make your source code even simpler.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top