Jump to content

Simple mysql_query Table Join help needed


shortysbest

Recommended Posts

I have two mysql tables, one is called "posts", the other is called "removed_posts", I have joined them together and can get some of the information from the tables, but I want to be able to get all of the information.

 

This is my query, and the variables I need the information to go to:

 

$quer = mysql_query("SELECT posts.id, removed_posts.post_id FROM posts, removed_posts WHERE posts.id=removed_posts.post_id AND removed_posts.user_id='".$session."'");
while($get_post = mysql_fetch_array($quer))
{
$session = $_COOKIE['id'];
$to_id = $get_post['to_id'];
$from_id = $get_post['from_id'];
$post = linkify(nl2br(htmlentities($get_post['post'])));
$date = time_stamp($get_post['date']);
$id = $get_post['id'];

 

What that's doing is selecting the id from 'posts' table, and selecting the post_id from the 'removed_posts' table (The query checks to make sure posts.id is equal to removed_posts.post_id), it does that just fine, since I defined what information I wanted it to get in the query, however, now I need to get the other information which will come from the 'posts' table.

 

$get_post['to_id'],

$get_post['from_id'],

$get_post['post'], and

$get_post['date']

 

I hope that's not toooooo confusing, any help would be appreciated

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.