Jump to content

Recommended Posts

Hey guys, This is my first proper php app. so be nice :)

 

I have a mysql_query that joins a two tables, it's working properly, but I want to add one extra variable with the results.

 

$topRanked = mysql_query("SELECT * FROM news JOIN users ON news.Username = users.Username WHERE users.connected='$yourname' ORDER BY created DESC") or die(mysql_error());

 

How this works is, I have 2 tables, one containing news stories and one with users...the users can be linked with one another, therefor you see their story.

This part works GREAT, but the user doesn't see his own stories.

 

Currenly it's getting every news story, except the users news story...how can I modify the QUERY that it also includes the users news stories?

Link to comment
https://forums.phpfreaks.com/topic/270936-mysql_query-join-one-extra-variable/
Share on other sites

Hey guys, This is my first proper php app. so be nice :)

 

I have a mysql_query that joins a two tables, it's working properly, but I want to add one extra variable with the results.

 

$topRanked = mysql_query("SELECT * FROM news JOIN users ON news.Username = users.Username WHERE users.connected='$yourname' ORDER BY created DESC") or die(mysql_error());

 

How this works is, I have 2 tables, one containing news stories and one with users...the users can be linked with one another, therefor you see their story.

This part works GREAT, but the user doesn't see his own stories.

 

Currenly it's getting every news story, except the users news story...how can I modify the QUERY that it also includes the users news stories?

 

I'm assuming you want to add an OR to your WHERE clause.

 

Currently you are only finding where the users.connected field matches, you probably want to add where the users.Username field also matches.

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.