I'm developing a news website with php-mysql.
This is the table:
news_id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
news_title VARCHAR(250) NOT NULL,
news_short_description TEXT NOT NULL,
news_full_content TEXT NOT NULL,
news_author VARCHAR(30) NOT NULL,
news_published_on DATE NOT NULL
)";
on the index page of the website will be shown the articles.
$sql = "SELECT news_id,news_title,news_short_description,news_full_content,news_author,news_published_on FROM ARTICOLI ORDER BY news_id DESC LIMIT 10";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "<h3>". $row["news_title"]. " </h3><br> " . $row["news_short_description"]. "<br> " ."Posted by ". $row["news_author"]. "<br>";
}
} else {
echo "0 results";
}
WHAT I NEED? i don't know how to create automatic pages and links for the single articles. EXAMPLE: www.website.com/this-is-the-title-of-the-article. i was thinking about using the id of the db table,but how to select one precise row? can you help me? thanks!!! ;)
where clauseto select specific row.WHERE news_id = 1will select only the row wherenews_idis1.WHERE news_id = '.(int)$_GET['news_id'].'