Jump to content

Contacts List - Needing Help


Dethman

Recommended Posts

Ok I had someone that was helping me on this but he dropped offline so you guys are my best bet.

 

Ok I have a table called Contacts in the SQL now there are 2 fields ContactID and OwnerID I need to grab all of the ContactID's and throw them at an sql query that gets the username assosiated with that id from a different sql table and then echo's each username ASC

How would I do that?

 

ContactID would be used like this

 

SELECT `Username` FROM `PlayerInfo` WHERE `id` = '{ContactID Goes Here}'

 

Any and all help would be apreciated,

Dethman

Link to comment
https://forums.phpfreaks.com/topic/150688-contacts-list-needing-help/
Share on other sites

Ok ill draw something out

 


// Say the User has 5 Contacts.. Here are there id's and a way to call them

$select="SELECT * FROM `Contacts` WHERE `OwnerID` = '".$_SESSION['id']."' ORDER BY `id` ASC";
$res=mysql_query($select) or die("Unable to Connect 1.<BR/>".mysql_error());
$row=mysql_fetch_array();

$cid=$row['ContactID'];

$cid_1 = $row['ContactID']; // Really 1
$cid_2 = $row['ContactID']; // Really 2
$cid_3 = $row['ContactID']; // Really 3
$cid_4 = $row['ContactID']; // Really 4
$cid_5 = $row['ContactID']; // Really 5

//Now I need to take each of those id's and do this to them.

$query="SELECT `Username` FROM `PlayerInfo` WHERE `id` = '".$cid_1."'";

$res=mysql_query($query) or die("Error Message".mysql_error());

$row=mysql_fetch_array($res);

echo $row['Username'];

//The User can have up to 1-100,000 Contacts I need to make it automated

 

Does that make any since?

maybe try this

 

$select="SELECT * FROM `Contacts` WHERE `OwnerID` = '".$_SESSION['id']."' ORDER BY `id` ASC";
$res=mysql_query($select) or die("Unable to Connect 1.<BR/>".mysql_error());

while($row=mysql_fetch_array($res))
{
$query="SELECT `Username` FROM `PlayerInfo` WHERE `id` = '".$row['id']."'";
$resa=mysql_query($query) or die("Error Message".mysql_error());
$rowa=mysql_fetch_array($resa);

echo $rowa['Username'];
}

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.