Trotterwatch Trotterwatch - 6 months ago 10
PHP Question

Displaying a PHP result

I am trying to learn php together with MYSQL. I have built the database on on the from end I have written the code below to bring in the website title from the database which works. However, I have two questions.


  1. How would I get the result to display in tags?

  2. Is this the cleanest way of pulling this value through?



Any help or advise greatly appreciated

<?php
include 'connection.php';

$sql = "SELECT VariableValue FROM VariableValues WHERE VariableID = '1'";
$result = $conn->query($sql);

while($header = $result->fetch_assoc()) {
echo $header["VariableValue"]. "<br>";
}

?>

Answer

You can echo all types of tags in PHP echo for example:

echo '<div class="col-md-6 col-md-offset-3 col-sm-8 col-sm-offset-2">
          <div id="success_alert" align="center" class="alert alert-success">
              <strong>Log in to download this chapter.</strong>
          </div>
      </div>';

I have echoed different types of bootstrap tags in echo. Similarly you can also echo all types of tags you want.

Comments