Jump to content

php align


chanfuterboy

Recommended Posts

hi,  echo 1 to 3, need to be center, and echo 4 need to be right, they are in the same line. how i can put it without use-ing   i try <td> also but seems not getting it help me

 

echo "<p align='center'>[<a href='profile.php' target='mFrame'>Profile</a>]  ";
echo "[<a href='profile.php' target='mFrame'>P.M</a>]  ";
echo "[<a href='profile.php' target='mFrame'>Add Friends</a>]      ";
echo "Welcome, ".$_SESSION['username']. "[<a href='logout.php'>Logout</a>]";

Link to comment
Share on other sites

well start off trying to use divs to place your information

example

<div id="main_content">
     <div id="center" style="align:center"><?=echo "<p align='center'>[<a href='profile.php' target='mFrame'>Profile</a>]  ";?></div>     
     <div id="center" style="align:center"><?=echo "<p align='center'>[<a href='profile.php' target='mFrame'>Profile</a>]  ";?></div>
     <div id="center" style="align:center"><?=echo "[<a href='profile.php' target='mFrame'>Add Friends</a>]      ";?></div>
     <div id="right_side" style="float:right"><?=echo "Welcome, ".$_SESSION['username']. "[<a href='logout.php'>Logout</a>]";?></div>
</div>

Link to comment
Share on other sites

well start off trying to use divs to place your information

example

<div id="main_content">
     <div id="center" style="align:center"><?=echo "<p align='center'>[<a href='profile.php' target='mFrame'>Profile</a>]  ";?></div>     
     <div id="center" style="align:center"><?=echo "<p align='center'>[<a href='profile.php' target='mFrame'>Profile</a>]  ";?></div>
     <div id="center" style="align:center"><?=echo "[<a href='profile.php' target='mFrame'>Add Friends</a>]      ";?></div>
     <div id="right_side" style="float:right"><?=echo "Welcome, ".$_SESSION['username']. "[<a href='logout.php'>Logout</a>]";?></div>
</div>

 

You cannot have multiple divs all with the same id.

Link to comment
Share on other sites

It's invalid code.

 

It's also divitis - there is no reason for that many divs at all. One div wrapping all of those <p> tags is enough. If each <p> tag needs to be styled separately, it can be given it's own class.

 

And finally, making an ID or class name be a description of the styling is not a good practice, as at some point in the future, the styling may change. For example, the three p tags that are left aligned may need to be switched to a right alignment at some time, at which point having an ID or class named 'left' doesn't make a lot of sense.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.