php - SELECT query inside html code gets no results -


i'm trying install php code inside html file present club friends using select query mysql. can't see results inside page. need help. here's entire php code (and html) integrated inside html:

<h2> club members</h2> <br/> <table dir="ltr" align="center" border="1"> <tr> <td><b>private name</b></td> <td><b>family name</b></td> <td><b>e-mail</b></td>   </tr>     <?php  // create connection $conn = mysqli_connect('localhost','root',"");  //check if connection opened, if not prompt error page. if (!$conn) {   die('could not connect: ' . mysqli_error()); }  //select data base. mysqli_select_db($conn, "club");  //set character set utf-8 allow hebrew. mysqli_query($conn, "set names 'utf8'");  //sql query - user details       $sql = "select fname, lname, mail customers";     $result = mysqli_query($sql);     while($row = mysqli_fetch_array($result))     {     ?> <tr> <td><?php echo $row["fname"] ?></td> <td><?php echo $row["lname"] ?></td> <td><?php echo $row["mail"] ?></td> </tr>     <?php     } ?> </table> 

thanks.

i think you've missed include connection link variable query , error functions. e.g.

$result = mysqli_query($sql); die('could not connect: ' . mysqli_error()); 

vs

$result = mysqli_query($conn, $sql); die('could not connect: ' . mysqli_error($conn)); 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -