I am new to PHP and web development in general. I wrote a simple PHP script based on my knowledge so far. Here it what it looks like, along with the HTML:
<!DOCTYPE HTML>
<html>
<title>Retrieve Users</title>
<meta charset="utf-8">
<body>
<p> List of Subscribers </p>
<?php
$query = "select * from subscribers";
$con = mysqli_connect("localhost","root","","subscribers");
$result;
if(mysqli_connect_errno()){
header("Location: unavailable.html");
exit;
}else{
$result = mysqli_query($con,$query);
}
?>
<table>
<?php
global $result;
while( $row = mysqli_fetch_array($result) ){
$email = $row['email'];
echo "<tr>";
echo "<td>" $email "</td>";
echo "</tr>";
}
?>
</table>
</body>
</html>
However, I get this in my webpage :
List of Subscribers
"; echo ""; echo ""; } ?>
" $email "
What changes do I need to make here?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…