Jump to content

[SOLVED] Insert HTML/CSS in PHP?


StroiX

Recommended Posts

Please help if possible.  The following code as of now produces the text on three separate lines, like this:

 

My Account

Edit Account

Logout

 

However, I would like to display in the following manner instead:

 

My Account Edit Account Logout

 

I would like to link the page to a style sheet and insert a div tag which will also have some other value such as color and etc.. of the hyperlinks.  I guess my question is then:

 

How is it possible to insert a div tag and <ul> tag the PHP code below so that I have an unordered list which I could later modify in CSS?  Please provide a working example if possible, thank you.

 

<?php
/**
* User has already logged in, so display relavent links, including
* a link to the admin center if the user is an administrator.
*/
if($session->logged_in){
      echo "<a href=\"userinfo.php?user=$session->username\">My Account</a>"
       ."<a href=\"useredit.php\">Edit Account</a>";
   if($session->isAdmin()){
      echo "<a href=\"admin/admin.php\">Admin Center</a>";
   }
   echo "<a href=\"process.php\">Logout</a>";
}
else{
?>

Link to comment
https://forums.phpfreaks.com/topic/162335-solved-insert-htmlcss-in-php/
Share on other sites

Please help if possible.  The following code as of now produces the text on three separate lines, like this:

 

My Account

Edit Account

Logout

 

However, I would like to display in the following manner instead:

 

My Account Edit Account Logout

 

I would like to link the page to a style sheet and insert a div tag which will also have some other value such as color and etc.. of the hyperlinks.  I guess my question is then:

 

How is it possible to insert a div tag and <ul> tag the PHP code below so that I have an unordered list which I could later modify in CSS?  Please provide a working example if possible, thank you.

 

<?php
/**
* User has already logged in, so display relavent links, including
* a link to the admin center if the user is an administrator.
*/
if($session->logged_in){
      echo "<a href=\"userinfo.php?user=$session->username\">My Account</a>"
       ."<a href=\"useredit.php\">Edit Account</a>";
   if($session->isAdmin()){
      echo "<a href=\"admin/admin.php\">Admin Center</a>";
   }
   echo "<a href=\"process.php\">Logout</a>";
}
else{
?>

 

<?php
/**
* User has already logged in, so display relavent links, including
* a link to the admin center if the user is an administrator.
*/
if($session->logged_in){
echo "<div class="/whatere u got"/>";
      echo "<ul><a href=\"userinfo.php?user=$session->username\">My Account</a></ul>"
       ."<ul><a href=\"useredit.php\">Edit Account</a></ul>";
   if($session->isAdmin()){

      echo "<ul><a href=\"admin/admin.php\">Admin Center</a></ul>";
   }
   echo "<ul><a href=\"process.php\">Logout</a></ul>";
echo "</div>";
}
else{
?>

 

hope this helps?

Thank for your reply.

 

I tried what you posted and I am getting the following error now, any suggestions?

 

 

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in /vservers/ssagarco/htdocs/login/index.php on line 37

 

Thank you.

 

<?php
/**
* User has already logged in, so display relavent links, including
* a link to the admin center if the user is an administrator.
*/
if($session->logged_in){
echo "<div class=\"whatere u got\">";
      echo "<ul><a href=\"userinfo.php?user=$session->username\">My Account</a></ul>"
       ."<ul><a href=\"useredit.php\">Edit Account</a></ul>";
   if($session->isAdmin()){

      echo "<ul><a href=\"admin/admin.php\">Admin Center</a></ul>";
   }
   echo "<ul><a href=\"process.php\">Logout</a></ul>";
echo "</div>";
}
else{
?>

 

sorry try this

Still same problem, here is the error again:

 

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in /vservers/ssagarco/htdocs/login/index.php on line 37

 

And line 37 is:

 

echo "<div class=\"login-quickmenu\">";

 

Please let me know if you would like me to try something else instead and thank you once again!

Do u at al know php?

 

<?php
/**
* User has already logged in, so display relavent links, including
* a link to the admin center if the user is an administrator.
*/
if($session->logged_in){
echo "<div class=\"login-quickmenu\">";
      echo "<ul><a href=\"userinfo.php?user=$session->username\">My Account</a></ul>";
       echo "<ul><a href=\"useredit.php\">Edit Account</a></ul>";
   if($session->isAdmin()){

      echo "<ul><a href=\"admin/admin.php\">Admin Center</a></ul>";
   }
   echo "<ul><a href=\"process.php\">Logout</a></ul>";
echo "</div>";
}
else{
?>

 

 

it wont give error again.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.