Jump to content

Recommended Posts

I am a noob working on my second script.

I have 2 tables A & B

Table A has 3 columns, the third column contains a number which represents the id of an entry in table B.

 

I know how to query table a for its 3 columns and can show that output in a dynamic table.

However this just shows the number in the thrid column....

 

I need to figure out how to take the number and fetch the correct entry from table b instead.

Any help would be appreciated.

Thank you for your time.

Link to comment
https://forums.phpfreaks.com/topic/88702-solved-join-2-tables-how/
Share on other sites

thank you for that link, it helps explain things a lot. But I am still having trouble making it work.

I belive the join code I need to use is..

 

SELECT *

FROM  cubes

      LEFT OUTER JOIN mobs

          ON drops_from.id = mobs.id

 

Should I be placing this in a query? I have tried to add the abovet o a query command but to no avail.

here is the code I am working with now...

 

Thank you in advance for any help you can give.

 

mysql_select_db($database_LWC, $LWC);
$query_Rs1_cubes = "SELECT * FROM cubes";
$Rs1_cubes = mysql_query($query_Rs1_cubes, $LWC) or die(mysql_error());
$row_Rs1_cubes = mysql_fetch_assoc($Rs1_cubes);
$totalRows_Rs1_cubes = mysql_num_rows($Rs1_cubes);

mysql_select_db($database_LWC, $LWC);
$query_Rs2_Mobs = "SELECT * FROM mobs";
$Rs2_Mobs = mysql_query($query_Rs2_Mobs, $LWC) or die(mysql_error());
$row_Rs2_Mobs = mysql_fetch_assoc($Rs2_Mobs);
$totalRows_Rs2_Mobs = mysql_num_rows($Rs2_Mobs);

?>

<html>
<body>
<table border="1">
  <tr>
    <td>id</td>
    <td>Cube Type</td>
    <td>Drops From</td>
  </tr>
  <?php do { ?>
    <tr>
      <td><?php echo $row_Rs1_cubes['id']; ?></td>
      <td><?php echo $row_Rs1_cubes['Cube Type']; ?></td>
      <td><?php echo $row_Rs1_cubes['Drops From']; ?></td>
    </tr>
    <?php } while ($row_Rs1_cubes = mysql_fetch_assoc($Rs1_cubes)); ?>
</table>
<p> </p>
</body>
</html>
<?php
mysql_free_result($Rs1_cubes);

mysql_free_result($Rs2_Mobs);
?>

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.