Jump to content

Recommended Posts

Hi, i have a table with this Structure:

 

    ID      ||    Inviter            ||      Reciever

    1      || test@test.com    ||  test1@test.com

    2      || test@test.com    ||  test2@test.com

    3      || test@test.com    ||  test3@test.com

    4      || test3@test.com  ||  test1@test.com

 

Information:

test@test.com has 3 invitations

test1@test.com has 2 invitations

test3@test.com has 2 invitations

test2@test.com has 1 invitation

 

i want an query to read the invitations made by his own inviters

 

Example:

test2@test.com has 1 inviter that is test@test.com(wich this one as 3), i want this query to show the other two inviters... wich are test1@test.com and test3@test.com.

 

This is what i've got so far but no success, i get inviters that the same inviter already as.

 

$testinv=mysql_query("SELECT Inviter, Reciever FROM invitations WHERE Inviter='$_SESSION[user]' OR Reciever='$_SESSION[user]' ORDER BY RAND() LIMIT 1"); ////// Gets a Random Friend of him
$testrow=mysql_flech_array($testinv);
if ($testrow['Inviter'] != $_SESSION['user']) $testrow=$dameamgdoamg1['Inviter'];
else $testrow=$testrow['Reciever']; ////// Choose the one that is not himself

$testinv1=mysql_query("SELECT Inviter, Reciever FROM invitations WHERE Inviter='$testrow' AND Inviter!='$_SESSION[user]' AND Reciever !='$_SESSION[user]' OR Reciever='$testrow' AND Inviter!='$_SESSION[user]' AND Reciever !='$_SESSION[user]'  ORDER BY RAND() LIMIT 1"); ////// Gets the Inviter of his Inviter
$testrow1=mysql_flech_array($testinv1);
if ($testrow1['Inviter'] != $testrow) $testrow1=$testrow1['Inviter'];
else $testrow1=$testrow1['Reciever'];   /////// Choose the one that is not himself

echo $testrow1.' invited your inviter '.$testrow

 

i hope you understand where im getting, and find a way out to this headshake i have.... Thank you all  :)

Link to comment
https://forums.phpfreaks.com/topic/72100-headshake-with-a-query/
Share on other sites

Example:

test2@test.com has 1 inviter that is test@test.com(wich this one as 3), i want this query to show the other two inviters... wich are test1@test.com and test3@test.com.

 

You say "the other two inviters" but test1 only appears in receivers column, so do you mean receivers, or are you working with one set of data but posting another?

 

example: for test3@test.com  i would get just test2@test.com

 

explain the logic for that statement, please

Ohh i think there is something missing here, i will example one sitiuation that will clear everything...

Example:

I(a) invite someone(b)

but someone© invites me too(a)

 

So the table would be like:

 

    ID      ||    Inviter            ||      Reciever

    1      ||      a                ||          b

    2      ||      c                ||          a

 

This leaves me with 2 invitations(invited b, and got invited by c).

 

what i want is b getting c.

 

Other example more complex:

 

 

    ID      ||    Inviter            ||      Reciever

    1      ||      a                ||          b

    2      ||      c                ||          a

    3      ||      d                ||          a

    4      ||      a                ||          e

    5      ||      d                ||          c

 

for b i get a, d and e.

for c i get b and e.

for a i get none since he as everyone

for e i get a

for d i get a and c

 

Don´t matter what collumn it belongs(Inviter or Reciever).

 

i hope i made myself clear and you find out a way out to this mess.  :-[

 

Thank you very much  ;)

  • 2 weeks later...
  • 2 weeks later...
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.