This code correctly displays the data from the remote server:
<?php $host="localhost"; $user="***"; $password="***"; $db_name="***"; $conn=mysqli_connect($host,$user,$password,$db_name); $sql="select * from goods"; $result=mysqli_query($conn,$sql); while($row = mysqli_fetch_array($result)) { echo $row["goods_id"]." ".$row["goods_name"]; echo "<br>"; } mysqli_close($conn); // header(string "Location:index.php"); ?> and this code displays an empty web page:
<?php $host="localhost"; $user="***"; $password="***"; $db_name="***"; $conn=mysqli_connect($host,$user,$password,$db_name); $sql="select * from goods"; $result=mysqli_query($conn,$sql); echo <table border='1'> <tr> <th>Goods_id</th> <th>Goods_name</th> </tr>; while($row = mysqli_fetch_array($result)) { echo "<tr>"; echo "<td>".$row["goods_id"]."</td>"; echo "<td>".$row["goods_name"]."</td>"; echo "</tr>"; } echo "</table>"; mysqli_close($conn); // header(string "Location:index.php"); ?> I can not find the reason. Please help.
echoconstruction supports theand so onoperator,and so on:echo 'str1', 'str2', 'str3';- passing arguments separated by commas. Works faster than string concatenation. - And