Hi.
I've searched the forums extensively for an answer... and I've tried the examples listed in every one of them... and had no luck at all.
I have two tables I need to extract data from. One is a "plane" table, where individual aircraft are stored, and one is a "user" table... where the users of the site are stored. Each user "owns" an aircraft, and they are assigned by adding the user_id field from the "user" table to the "plane" table. They look like this:
USER
user_id (auto_increment)
name
location
email
PLANE
plane_id (auto_increment)
user_id
name
type
status
So... in essence, what I have is something like this:
USER
====
1 2 3 4
Bob Mike Sally John
USA UK USA USA
[email]bob@aol.com[/email] [email]mike@aol.com[/email] [email]sally@aol.com[/email] [email]john@aol.com[/email]
PLANE
=====
1 2 3 4
2 4 1 3
Mike's Plane John's Plane Bob's Plane Sally's Plane
B-17G B-17F B-17G B-17F
ok ok ok shot down
Now... I have a page, where I want to display the aircraft (as the basis), with the type and user details... like below:
$display_block .= "<font size-2 color=#00000><b>$plane_link</b> :<font size=1> ($plane_type) - $user_name ($user_email)</font></font><br>";
I am having a HELL of a time extracing the information out of the two tables to populate the above PHP block!!
I can't seem to get the data from one or the other table depending on my code. Here's my latest attempt:
// Create Aircraft Query //
$plane_query = "SELECT * FROM $user, $plane WHERE plane.user_id = 'user.user_id' AND plane.squadron = '358th' AND plane.status = '0' ORDER BY plane.plane_id ASC";
$plane_result = @mysql_query($plane_query, $connect) or die(mysql_error());
while ($row = mysql_fetch_array($plane_result)) {
$plane_name_long = $row['plane.name'];
$plane_name_fix = str_replace(" ", "%20", $plane_name_long);
$plane_link = "<a href=aircraft.php?name=$plane_name_fix><font color=#30341B><b>$plane_name_long</b></font></a>";
$plane_type = $row['plane.type'];
$plane_user_id = $row['plane.user_id'];
$user_name = $row['user.name'];
$user_email = $row['user.email'];
}
Anyone have any ideas what I'm doing wrong? I can't figure it out... and I don't want to have a whole bunch of queries to dig up the information... that's just sloppy, and I don't want to get into the habit of writing sloppy code.
Thanks...