can't get the post to show to the user only
Posted: Sun Sep 16, 2012 12:19 pm
				
				I have a function and can't make it work. I tried many things but still no luck.

			function get_posts($id = null, $category_id = null) {
	$posts = array();
	$query = "SELECT  `posts`.`id` AS  'post_id',  `categories`.`id` AS  'category_id', 
			`title` ,  `content` ,  `date_posted` , `categories`.`name` 
			FROM  `posts` 
			INNER JOIN  `categories` ON  `categories`.`id` =  `posts`.`category_id`";
			
	if (isset($id)) {
	$id = (int)$id;
	$query .= "WHERE `posts` . `id` = '{$id}'";
	}
	
	if (isset($category_id)) {
		$category_id = (int) $category_id;
		$query .= "WHERE `category_id` = '{$category_id}'";
	}
	
	$query .= "ORDER BY `posts` . `id` DESC";
			
	$query = mysql_query($query);
	
	while ($row = mysql_fetch_assoc($query)) {
		$posts[] = $row;
	}
	return $posts;
}
How do I make it show only to the user who posted it, not to all the users. It's supposed to work like a diary.