Jump to content

Headshake with a Query


solgun

Recommended Posts

Hi, i have a table with this Structure:

 

    ID      ||    Inviter            ||      Reciever

    1      || [email protected]    ||  [email protected]

    2      || [email protected]    ||  [email protected]

    3      || [email protected]    ||  [email protected]

    4      || [email protected]  ||  [email protected]

 

Information:

[email protected] has 3 invitations

[email protected] has 2 invitations

[email protected] has 2 invitations

[email protected] has 1 invitation

 

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

 

Example:

[email protected] has 1 inviter that is [email protected](wich this one as 3), i want this query to show the other two inviters... wich are [email protected] and [email protected].

 

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:

[email protected] has 1 inviter that is [email protected](wich this one as 3), i want this query to show the other two inviters... wich are [email protected] and [email protected].

 

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 [email protected]  i would get just [email protected]

 

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...

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.