needing data from several different tables
Posted: Thu Jul 15, 2004 6:48 am
ok its hard to explain but basically im trying not to use joins and use seperate queries (this code is for someone else, someone who doesnt understand JOIN syntax)
im wondering if theres anyway around the following problem im having, please read comments.
any ideas?
im wondering if theres anyway around the following problem im having, please read comments.
Code: Select all
// we need to get the username from one table
$query_1 = "SELECT customer_id, username FROM members";
$result_1 = mysql_query($query_1) or die (mysql_error());
// get initial array
$array_usernames_1 = mysql_fetch_array($result_1, MYSQL_ASSOC);
// PRINT SOME OUTPUT TO THE BROWSER HERE
// LIKELY - <td>$array_usernames_1['username']</td>
// we now need to find some information from another table
// the field with a common relationship is customer_id
$query_2 = "SELECT customer_id, paypal_acc FROM paypal WHERE customer_id = '$array_usernames_1[customer_id]'";
$result_2 = mysql_query($query_2) or die (mysql_error());
// create another array with this value
$array_paypal_1 = mysql_fetch_array($result_2) or die (mysql_error());
// MORE PRINTING TO THE BROWSER
// now here i need to fetch the rest of the resultset using mysql_fetch_assoc
// however i am unsure on how to do this in this 'instance'