-17

I want to display a database table in my .php web page. I use the following code:

<?php
        include('../dbconnect.php');
        $det= SELECT * FROM user ;
        $result=mysqli_query($con,$det);
         mysqli_close($con);

         while($row=mysqli_fetch_array($result))
         {

            echo '<table style="width: 100%">
                <tr>';
                    echo "<td>".$row['name']."</td>";
                    $del=$row['uid'];
                    echo '<td><a href=functions/deleteuser.php?id=' .$del.'>Delete</a></td>
                </tr>
            </table>';

         }
    ?>

But, when I include this code, the whole web page appears as blank. Without this code, the page works fine. What is wrong with this code?

Litisqe Kumar
  • 2,512
  • 4
  • 26
  • 40
Jayesh Babu
  • 1,389
  • 2
  • 20
  • 34

4 Answers4

5

It should be like this

$det = 'SELECT * FROM user';
stollr
  • 6,534
  • 4
  • 43
  • 59
CodeSlayer
  • 1,318
  • 1
  • 12
  • 34
4

The query should be used in double/single quotes. Like this.

$det = 'SELECT * FROM user' ;
Mad Angle
  • 2,347
  • 1
  • 15
  • 33
2

query not quoted try this

$det= "SELECT * FROM `user`";
Satish Sharma
  • 9,547
  • 6
  • 29
  • 51
-3

mysqli_close($con); should be at the bottom after your while loop. Try doing this.

ThS
  • 4,597
  • 2
  • 15
  • 27