Question: I have a link on a website when it's clicked it will load a form in a div. The form is processed by a PHP script. I need the output from the PHP script to appear in that div. Any idea how to do this? Thanks

File header.php

```
<html>
    <head>

    <script>
          $(document).ready(function(){

                $('#mylink').click(function(){

                       $('#content').load("form.php");
                  });    

          });

</script>

</head>

<body>

     <li><a href="#" id="mylink">Add Account</a></li>

```

file index.php

```
<?php

       include_once 'header.php';

 ?>

 <div id="content"></div>

```

in form.php 

```
  <form id= method="POST" action="script.php">
        ......
        ........

     <input type="submit" value="Add account" />

 </form>

```

in script.php

i need to send error message or thank you note in div #content

Answer: 
There are a couple of ways you can achieve this. 

Lets say you have an anchor tag `<a href="..">My Href</a>` and you want to add CSS to it based on certain instances. 

You can easily echo that css into the anchor element like so: 

`<a <?php echo 'style="float: left;"'; ?> href="..">My Href</a>`

The output would be: 
`<a style="float: left" href="...">My Href</a>`

You can do this with almost any HTML element. 

Now let's say you have a predefined CSS class you would like to echo into an anchor tag element. 

Let's say you have this CSS class in your stylesheet:

```
.floatLeft {
    float: left;
}

```

You can simply echo that class into the anchor element like so: 

`<a href="..." class="<?php echo 'floatLeft'; ?>">My Href</a>`

Which the output of that would be: 

`<a href="..." class="floatLeft">My Href</a>`
Yes. It is possible. 

There's actually two different ways. 

**Method 1:** Inject PHP into your actual CSS. This is done by making your file .php, using regular HTML and CSS, and then doing as such: 

```
.someclass {
/* Some code */
<?php // Whatever you wanna inject 
?>

```

I have performed this many times, and no one knows. It may not be the most efficent way, but it's also sometimes better than doing...

 **Method 2:** Escape your quotes and lines. 

Use: 

```
    echo("/* Your css code here */ \ (to escape the line return
        /* Whenever there is a quote, make sure to do the following: \" ");

```

If you don't escape the quote, PHP will think you're ending the string. That's bad, because the rest of your text gets ignored. 

ADDITIONAL NOTE: You don't have to use print for echoing HTML. Echo works too.