Last response got me into researching various joins to actually query multiple databases at once. Still failing. I've also posted to different forums and getting sorta sad that there doesn't seem to really be any solution to it. I've tried for over a week and still get bugs.
Here's the rough of it.
Using and reading up on joins and various ways of query multiple tables at same time to get an array of rows, I haven't been able to find anything that works for me.
The query roughly, that I've experimented is something like:
$sql = "SELECT m.member_name, (m.member_earned-m.member_spent+m.member_adjustment) AS m.member_current, m.member_earned, m.member_spent, m.member_adjustment, m.member_lastraid,
p.pid, p.pname, w.rid, w.pid, w.iid
FROM " . MEMBERS_TABLE . " m, " . W_PLAYER_TABLE . " p, " . W_REQUEST_TABLE . " w
WHERE w.iid='$iid' AND (m.member_name = p.pname) AND (w.pid=p.pid)
ORDER BY m.member_current";
The purpose is to get a array to loop through, with the columns I've selected.
Best result I have gotten was
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource
Looping only through table 3 at first, I can get all the data output I want. By using mysql fetch assoc instead.
But that loses the ability to order output by m.member_current since all data from MEMBERS_TABLE is gotten after the loops has already started.
I thought I had it when I finally came up with:
$reqres= mysql_query("SELECT m.member_name, m.member_earned, m.member_spent, m.member_adjustment
(m.member_earned-m.member_spent+m.member_adjustment) AS m.member_current
m.member_lastraid, p.pid
FROM " . MEMBERS_TABLE . " m, " . W_REQUEST_TABLE . " w
RIGHT JOIN " . W_PLAYER_TABLE . " p
ON m.member_name = p.pname
WHERE (w.iid = '$iid') AND (w.pid = p.pid)");
while ($row = mysql_fetch_array($reqres))
{ (insert PHP formatting of output here)
}
but again, I get the Warning.
I've been trying my best, debugging this to bits. What I really want to know is, can someone come up with a query to actually do what I want this to do:
Have a preset $iid that I want to look up who requested p.pid=w.pid and then loop through the member data of said player by looking up p.pname and looping through p.pname's records by setting it = to m.member_name. Then to finish it all off order this by a value I set in sql m.member_current.
Thanks for the comments so far.