1

I have to add an html id tag to give some css properties inside this php code and I don't know how to do that?

   <?php

   //Start your session
   session_start();
   //Read your session (if it is set)
   if (isset($_SESSION['user_login'])){

 echo $_SESSION['user_login'];
         }
?>

I have to add css property for that echo.

Bajwa kapoor
  • 73
  • 3
  • 12

3 Answers3

1

may be you want something like this -

if (isset($_SESSION['user_login']))
{ 
echo '<div id="YOUR-ID-HERE">'.$_SESSION['user_login'].'</div>';
}
Abhishek Sharma
  • 6,689
  • 1
  • 14
  • 20
Sachin Vairagi
  • 4,894
  • 4
  • 35
  • 61
0

This is simple HTML 101,

<tagname id="idValue">

Have you tried looking though w3schools

Can O' Spam
  • 2,718
  • 4
  • 19
  • 45
  • What areyou trying to do? Can you edit your question so we can see what you are doing? What error do you get etc. – Can O' Spam Nov 17 '15 at 12:42
0

You need to enclose (wrap) your PHP output in a div.

And then give id to that div.

<div id="YOUR_CSS_ID_HERE">
<?php echo $_SESSION['user_login'];?>
</div>

Also, no need for brackets ( and ) for echo as it is a language construct, not a function.

Pupil
  • 23,834
  • 6
  • 44
  • 66