vendredi 2 mars 2018

what is a good way to display a php variable on html [duplicate]

This question already has an answer here:

I've been trying to implement a hit counter to my website and this is the php code I wrote, the code works fine I tested it separately, but when I add the script in the html file the code doesn't work and the html output is weird

here's how my code looks:

<li class="nav-item">
            <!--phpcode-->
        <?php
            $connect=mysqli_connect('localhost','root','root');
            mysqli_select_db($connect,"innovata");
            mysqli_query($connect,"UPDATE hitcounter SET value=value+1 WHERE name='hits'");
            $result = mysqli_query($connect,"select * from hitcounter where name='hits'");
            $p=mysqli_fetch_assoc($result);
            echo "<li class="nav-item">
                    <a class="nav-link js-scroll-trigger" href="">Visitors:".$p['value']."
                    </a>
                </li>"; 
      ?></li>

This is how I want it to look like.

This is how it looks like.

Aucun commentaire:

Enregistrer un commentaire