Im trying to make a simple blog with php. What I'm doing is to link a post to lists of post on the blog. For example, just like this.
Example of a posts list and a post viewer i planned
So there's two different parts of source. First of all, this source shows the lists of posts existing on the blog.
<?php
$host = 'localhost';
$user = 'root';
$password = 'root';
$db = 'urls';
$port = 8889;
$conn = mysqli_connect($host, $user, $password, $db, $port);
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
$sql = "SELECT id, title, url, votes FROM link ORDER BY id DESC LIMIT 10";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
// output data of each row
while ($row = mysqli_fetch_assoc($result)) {
echo '
<li class="list-group-item">
<span class="badge">' . $row['votes'] . '</span>
<button type="button" class="btn btn-info">Like</button>
<button type="button" class="btn btn-danger">Hate</button>
<a href="#" onClick="location.href='post_link.php'" >' . $row['title'] . '</a>
</li>';
}
} else {
echo "0 results";
}
mysqli_close($conn);
?>
I linked the title of a post to another php file, but it seems like its not working.
<a href="#" onClick="location.href='post_link.php'" >' . $row['title'] . '</a>
</li>';
And this source is the page where i show specific details of a post.
<div class="panel panel-default">
<div class="panel-heading"><? echo $row['title'] ?></div>
<div class="panel-body">
<? echo $row['url']?>
<button type="button" class="btn ban-info">Like</button>
<button type="button" class="btn ban-danger">Hate</button>
</div>
</div>
However, its not working as well. So how can i solve this problem?
try some thing like this <a href="www.site.com/post_link.php/$row['title']">Text</a>