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
https://forums.phpfreaks.com/topic/19399-php-query-question/
Share on other sites

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.