Help With PHP?

iRawrHotel

Member
Mar 4, 2012
41
0
Hello,
I'm learning PHP,
and I'm wondering what it's called when you use info from a database, to generate a URL, such as that used in RevCMS for news, where it loads the ID, and shows the news article relating to that ID.

&

Can anyone link me to a good tutorial on PHP Sessions?
I'm trying to get it to work but it's hard!!!

Thanks in advance
 

Markshall

Русский Стандарт
Contributor
Dec 18, 2010
2,638
2,393
Never recommend W3Schools, it's a piece of shit.

Something like this should do.

PHP:
<?php
include('inc/db.php');
//...
 
$NewsID = (int) $db->escape_string($_GET['id']);
 
$NewsQ = $db->query("SELECT * FROM `News` WHERE `NewsID` = '{$NewsID}'");
if ($NewsQ->num_rows > 0) {
    $NewsA = $NewsQ->fetch_assoc();
 
    echo '<h3>' . $NewsA['Title'] . '</h3>';
    echo '<hr />';
    echo '<p>' . htmlspecialchars($NewsA['Content']) . '</p>';
}else{
    echo 'This news article does not exist.';
}
?>
 

Users who are viewing this thread

Top