Combining HTMTL with PHP code

Hi everyone,
With “escaped codes” ("heredoc ") I manged to display variables on my display whereby PHP and HTML combination.
using HTML file with PHP snippets I fail to show variable values.
here is the code:

<?php
require_once 'myInitial.php';
require_once 'myLogin.php';
MYSQLI_SET_CHARSET($myConnection,'UTF8');
?>
<!DOCTYPE html>
<!--forum_titles.html-->
<html>
  <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <head>
<body>
  <table>
    <tr>
      <th>counters</th>
    </tr>
    <?php
      $myQue = "SELECT  counter FROM hourshifts";
      $myResult = $myConnection->query($myQue);
      if (!$myResult) die ("Database access failed: " . $myConnection->error);
      $numOfRows = $myResult->num_rows;
      echo $numOfRows;
      for ($j = 0 ; $j < $numOfRows ; $j++)
      {
        $myResult->data_seek($j);
        $row = $myResult->fetch_array(MYSQLI_ASSOC);
      ?>
      <tr>
         <td><?php {$row["counter"]} ?></td> 
      </tr>
      <?php
         }
      ?>
   </table>
</body>
</html>

Variable " $numOfRows" is displayed correctly (203 rows) but “counter” column values becom null on my display as shown at the attached screenshot.

could anyone, please, explain why the values extracted from my SQL query are not displayed?
Thanks


to-forum-combine.gif

You are not using a heredoc statement.

[php]<?php {$row["counter"]} ?>[/php]
Doesn’t do anything.

This prints the statement when done how you have it,
[php]<?php echo $row["counter"]; ?>/[/php]

Thank you so much !

[php]<?= $row["counter"] ?>[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service