我正在建立一个新闻共享网站,由于我没有使用PHP的经验,所以我在互联网上查找了如何建立一个新闻共享网站。但是当我用完PHP时,网站上的PHP杂乱无章
我的代码是(mugg.php):
<?php
require_once("connection.php");
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>mugg. | Pradinis</title>
<link>
</head>
<body>
<div class="header">
<h2>mugg.</h2>
</div>
<div class="menu">
<a href="index.php">Pagrindinis</a>
<a href="#">Pasiekite mus</a>
</div>
<div class="content">
<?php
$q='SELECT `id`, `post_title` FROM `post` WHERE `status`="paskelbta"';
$r=mysqli_query($con, $q);
if($r){
if(mysqli_num_rows($r) > 0){
while($row = mysqli_fetch_assoc($r)){
$id = $row['id'];
$post_title = $row['post_title'];
echo '<a href="?id='.$id.'">'.$post_title.'</a>';
}
}else{
echo 'no post';
}
}else{
echo $q;
}
?>
</div>
</body>
</html>
(connection.php):
<?php
$con = mysqli_connect("localhost", "root", "", "mugg_website");
?>