-1

I want to retrieve data from Database to Html bootstrap table here is my code for php and html both:

                    <div class="ibox-title">
                        <h5>Data Tables example</h5>
                    </div>
                    <div class="ibox-content">

                    <table class="table table-striped table-bordered table-hover dataTables-example" >
                    <thead>
<?php
$con = mysql_connect("localhost","pooling","password");
if (!$con)
{
  die('Could not connect: ' . mysql_error());
}   
mysql_select_db("bayansh_bmc", $con);
$result = mysql_query("SELECT * FROM pooling");
while($row = mysql_fetch_array($result))
{
                    <tr>
                        <th>Province</th>
                    </tr>
                    </thead>
                    <tbody>
                        echo "<td>" . $row['Province'] . "</td>";
                    </tbody>
                    </table>
mysql_close($con);

?>
                    </div>
                </div>
            </div>
            </div>
        </div>
        </div>
        </div>

it gives me error at line 78 which is echo "";

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
Kho Dam
  • 17
  • 1
  • 7
  • `{ ` pure HTML in PHP. – Funk Forty Niner Sep 22 '16 at 19:33
  • What the flippin ek is that – RiggsFolly Sep 22 '16 at 19:35
  • Every time you use [the `mysql_`](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php) database extension in new code **[a Kitten is strangled somewhere in the world](http://2.bp.blogspot.com/-zCT6jizimfI/UjJ5UTb_BeI/AAAAAAAACgg/AS6XCd6aNdg/s1600/luna_getting_strangled.jpg)** it is deprecated and has been for years and is gone for ever in PHP7. If you are just learning PHP, spend your energies learning the `PDO` or `mysqli` database extensions. [Start here](http://php.net/manual/en/book.pdo.php) – RiggsFolly Sep 22 '16 at 19:35
  • And while we're on the subject of ``, you should have a `...` inside the ``. For that matter, the while loop probably belongs inside the ``. – Juan Tomas Sep 22 '16 at 19:35
  • I officially hate the new school/college year – RiggsFolly Sep 22 '16 at 19:36
  • @fred-ii- Then how to get value from php to – Kho Dam Sep 22 '16 at 19:37

1 Answers1

0

Basic tip: HTML is not PHP code:

php mode:            while($row = mysql_fetch_array($result))
php mode:            {
html-in-php-mode:        <tr>

You can't mix php and html like that. You HAVE to use <?php ... ?> to tell the parser where your PHP code starts/ends:

while($row = mysql_fetch_array($result))
{  ?>
    ^---note this
    <tr
Marc B
  • 356,200
  • 43
  • 426
  • 500