-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,442
  • 4
  • 24
  • 39
Jayesh Babu
  • 1,306
  • 1
  • 18
  • 31

4 Answers4

5

It should be like this

$det = 'SELECT * FROM user';
naitsirch
  • 5,968
  • 4
  • 41
  • 54
CodeSlayer
  • 1,295
  • 1
  • 12
  • 34
4

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

$det = 'SELECT * FROM user' ;
Mad Angle
  • 2,290
  • 1
  • 14
  • 31
3

query not quoted try this

$det= "SELECT * FROM `user`";
Satish Sharma
  • 9,475
  • 6
  • 27
  • 51
-4

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

ths
  • 3,084
  • 1
  • 14
  • 24