Blog Editor

Okay so for my final project we decided to make a blog editor. I am in charge of the page that displays the lists of posts specific to the user who is logged in. What I want to do is have one page that displays posts based off of who is logged in, and if no one is logged in it will just display that they must be logged in. All of our data is stored in a MySQL database, so what I need to figure out is

A. How to display information specific to the user who is logged in

Here is my code:

[php]<?php session_start(); ?>[/php]

<html>
<head>

<title>List of Posts</title>

</head>

<body style="margin: 0px; padding: 0px; font-family: 'Trebuchet MS',verdana;">

<table width="100%" style="height: 100%;" cellpadding="10" cellspacing="0" border="0">
<tr>


<td colspan="3" style="height: 100px;" bgcolor="#6D98AB"><h1>Blog Editor</h1></td></tr>



<tr><td colspan="3" valign="middle" height="30" bgcolor="#A8B1B8"><a href="#">Home</a></td></tr>

<tr>

<td width="20%" valign="top" bgcolor="#B0C4DE">

</td>


<td width="55%" valign="top" bgcolor="#FFFFFF">

<h2>UserNameHere's Posts</h2>
[php]
    <?php
// Perform database query
$connection = mysql_connect("localhost", "ajmaurer", "soici211");

if(!$connection) {
	die("Database connection failed: " . mysql_error());
}

// Select a database to use
$db_select = mysql_select_db("ajmaurerdb", $connection);
if(!$db_select) {
	die("Database selection failed: " . mysql_error());
}

$result = mysql_query("SELECT * FROM POSTS", $connection); 
if (!$result) {
	die("Database query failed: " . mysql_error());
}

// Use returned data
while ($row = mysql_fetch_array($result)) {
	
	echo $row[4]." <br />";
}

mysql_close($connection);
?>
    [/php]
</td>

<td width="25%" valign="top" bgcolor="#B0C4DE">&nbsp;</td>

</tr>


<tr><td colspan="3" align="center" height="20" bgcolor="#6D98AB"></td></tr>
</table>
</body>

</html>
Sponsor our Newsletter | Privacy Policy | Terms of Service