So in PHP I have the following:
$result = db_query("SELECT * FROM siteData WHERE category = '$temp_cat' ORDER BY id DESC LIMIT $offset, $rowsperpage");
// db_query() is a custom function which executes mysqli queries to the db
I'm displaying the id
in my post HTML and use it as a permalink to the post. That's all good, but when I decide to filter by category I see the following:
Main page
:-Post Title-
-2- <-- Post ID
-Post Content-
-Post Footer-
-Post Title-
-1- <-- Post ID
-Post Content-
-Post Footer-
About Page
:-Post Title-
-4- <-- Post ID
-Post Content-
-Post Footer-
-Post Title-
-3- <-- Post ID
-Post Content-
-Post Footer-
And so on... What I mean with this is that posts have misleading IDs that are set upon post creation and automatically increase. This leads to About Page
beginning with post that has id = 3
and not id = 1
. Is there any possible way to make it count IDs for different categories separately?
As per discussion, this is what I have in my select.php
file:
<?php
while ($row = mysqli_fetch_array($result)) {
$id = $row['id'];
$title = $row['title'];
$category = $row['category'];
$date = $row['date'];
?>
Category: “<?php echo $category; ?>”
 <span class="fa fa-fw fa-lg fa-chevron-right" aria-hidden="true"></span> 
Title: <a href="edit.php?id=<?php echo $id; ?>" hreflang="en">“<?php echo $title ?>”</a>
 <span class="fa fa-fw fa-lg fa-chevron-right" aria-hidden="true"></span> 
Date: <time datetime="<?php echo $date; ?>"><?php echo $date; ?></time><br>
<?php
}
?>
I then SELECT
the post by the id
which I $_GET
from the URI and display some form
-specific elements that hold the post values. Then I update the data in the db.