Return to Snippet

Revision: 40716
at February 6, 2011 02:38 by AzNGTX2


Initial Code
<?php

$db = mysql_connect("localhost", "username", "password") or die("Could not connect to database.");
if(!$db)
die("no db");
if(!mysql_select_db("blog",$db))
die("No database selected.");

$id = $_GET['id'];

$fid="SELECT * from blog where blogid='$id'";
$fid2=mysql_query($fid) or die("Could not get data");
$fid3=mysql_fetch_array($fid2);

$blogid = $fid3['blogid'];

if ($blogid > 0.1)
echo "";
else
header("Location: index.php");
?>

<?php

//mysql database connection
$dbhost='Database Host';
$dbuser='Your Username';
$dbpass='Your Password';
$dbtable='Your Table Name';

mysql_connect("$dbhost", "$dbuser", "$dbpass") or die("Could not connect.");
mysql_select_db("$dbtable") or die("Table could not be selected.");

$id=$_GET['id'];

$fblogid=mysql_query("SELECT * from blog where blogid='$id'") or die("Could not load the entries.");
$fblogid2=mysql_fetch_array($fblogid);

$message=($fblogid2['message']);
$message=nl2br($message);
$date=($fblogid2['date']);

print "";

$fshow=mysql_query("Select * from blog where blogid='$id' order by blogid asc") or die("Could not find blog posts.");
while($fshow2=mysql_fetch_array($fshow))

{

$message=($fshow2['message']);
$message=nl2br($message);

print "$message<br/><hr><p align='right'>Posted on: $date</p><br>";

}
?>

Initial URL


Initial Description


Initial Title
PHP Blog: Index.php

Initial Tags


Initial Language
PHP