Jump to content

PHP Query Question....


jjdave

Recommended Posts

Hi All, any help will be appriciated. Thanks.
I am trying to JOIN 3 Tables (X & Y & Z) with 1 Column (partlist_id) and my query does not work. I can not print the results.
[code=php:0]$query="SELECT x.id, x.assy_part,
  y.part_no, y.part_desc, 
  z.roll_id,  z.roll_image
  FROM `$table_name` as x 
  INNER JOIN `$vpt_table_partlist` as y ON y.partlist_id = x.partlist_id
  INNER JOIN `$vpt_table_rollover` as z ON z.partlist_id = x.partlist_id";
$result=mysql_query($query);
$num=mysql_numrows($result);

echo "<TD><br>";
$i=0;
while ($i < $num) {
  $id=mysql_result($result,$i,"id");
  $part_no=mysql_result($result,$i,"part_no");
      echo "$id : $part_no";
  $i++;
}
echo "</TD></TR>";[/code]


If I remove Table Z and only JOIN Table X & Y, with following code, then it works fine.
[code=php:0]$query="SELECT x.id, x.assy_part, y.part_no, y.part_desc
  FROM `$table_name` as x 
  INNER JOIN `$vpt_table_partlist` as y ON y.partlist_id = x.partlist_id";
$result=mysql_query($query);
$num=mysql_numrows($result);

echo "<TD><br>";
$i=0;
while ($i < $num) {
  $id=mysql_result($result,$i,"id");
  $part_no=mysql_result($result,$i,"part_no");
      echo "$id : $part_no";
  $i++;
}
echo "</TD></TR>";[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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