close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Recordset with 2 JOINS

Thread began 1/07/2011 2:11 pm by dan361748 | Last modified 1/07/2011 3:54 pm by dan361748 | 881 views | 1 replies


Recordset with 2 JOINS

Hi - I realize this is more of a mySQL/PHP question but hopefully some kind soul out there can point out what I am doing wrong.

My records have 2 fields: location1provstate and location2provstate

In my forms I have inserted the ID from the table states_provinces for the fields above.

However when I am trying to display my records I can't figure out how to reference the separate values from the lookup table. Here is what I have:

mysql_select_db($database_boomcms, $boomcms);
$query_Recordset1 = "SELECT listings.*, states_provinces.* FROM ((listings LEFT JOIN states_provinces ON states_provinces.StateID=listings.location1provstate) LEFT JOIN states_provinces AS states_provinces_0 ON states_provinces_0.StateID=listings.location2provstate) ";
$Recordset1 = mysql_query($query_Recordset1, $boomcms) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);

<?php do { ?>
<?php echo $row_Recordset1['name']; ?><?php echo $row_Recordset1['StateName']; ?><br />
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>

<?php echo $row_Recordset1['StateName']; ?> gives me the correct value for location1provstate from the states_provinces lookup table but obviously I also need to get location2provstate.

I have tried <?php echo $row_Recordset1['states_provinces.StateName']; ?> and <?php echo $row_Recordset1['states_provinces_0.StateName']; ?> but I don't get anything back.

Can someone point out what I am doing wrong?

Many thanks.

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question





Ease of use


security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...