Hi Guys,
i have 2 main tables "membership" and "member_comments" i have made a page which trys to pull out the data according to who is logged in my script is like this:
what was trying to do is display the "posted comments" for the logged in user so they could then "edit or delete" them, but im not having much luck with the quer i can SELECT * FROM member_comments fine, but i only want the comments displayed for that particular logged in user not EVERY comment ever posted lolPHP Code:<?php
// For register_global on PHP settings//////////////////////////////////////////////
$member = $_COOKIE['member'];
session_start(); // you must put this to read session variables/////////////////////
if (empty($member) || !isset($member)) // fail to read the browser cookie///////////
{
// Try to read session
if (empty($_SESSION['member']) || !isset($_SESSION['member']))
{
header("Location: login.php"); // redirect user to login//////////////////////
exit;
} else {
$member = $_SESSION['member'];
}
}
//Includes... //////////////////////////////////////////////////////////////////////
include("includes/db_connection.php");
include("includes/constants.php");
include("includes/header.php");
include("includes/loginnav.php");
$query = "SELECT id,username FROM membership WHERE username='$member' LIMIT 1";
$result_query = mysql_query($query) or die(mysql_error());
while($result_array = mysql_fetch_array($result_query)) {
?>
<p align="left">Welcome, <b><font color="#3399ff"><? echo $_COOKIE['member'] ?></font></b>! (<a href="logout.php">Logout</a>) - [ <a href="change_password.php">Change Password Or E-mail Address</a> ]-[ <a href="edit_profile.php">Edit Profile</a> ]-[ <a href="upload_photo.php">Upload Photo</a> ]-[ <?php echo "<a href='profile.php?id=$result_array[id]'>View My Profile</a>"; ?> ]-[ <a href="edit_blog.php">Edit Blog</a> ]</p>
</p>
<?php
}
?>
<p>Edit The Comments On Your Profile Blog Below:</p>
<?php
// Make a query to retrieve the comments.../////////////////////////////////////////
$query2 = "SELECT * FROM member_comments WHERE uid='$member' LIMIT 1";
$result2 = mysql_query($query2) or die(mysql_error());
while ($row = mysql_fetch_array($result2)){
$mid = $row['mid'];
$comments = $row['comments'];
echo $comments;
echo "<br />";
}
?>
heres the .sql for member_comments if it's needed
Thanks for nay helpPHP Code:CREATE TABLE `member_comments` (
`id` int(5) NOT NULL auto_increment,
`mid` varchar(5) NOT NULL default '',
`uid` varchar(5) NOT NULL default '',
`comments` text NOT NULL,
`posted` datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=33 ;
Graham




Bookmarks