close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Help with inner join query

Thread began 8/12/2010 1:34 am by iainmacdonald331081 | Last modified 8/13/2010 12:40 am by iainmacdonald331081 | 5331 views | 16 replies

iainmacdonald331081

Help with inner join query

This is probably slightly beyond DA's functionality, but thought I'd ask here anyway, as you guys have been great with support in the past, and hopefully isn't that complicated for the experts!

Basically I have the following table structure :

table : packages

packageID
package
packageDetails
etc

table : destinations

destinationID
destination
destinationDetails
etc

table : packagedestinations

packageID
destinationID

..so nothing that complicated.

So the idea is that I can have a package details page which shows the details of the package, along any destinations linked to that package via the packagedestinations table.

So this is the last part really - to get the page to display the destinations, but I'm missing something along the way, as I can't get the destinations to display on the page here :

packageDetailsTest3.php?packageID=128

This is the PHP from the header, including my INNER JOIN query....

php:
<?php 

$ParampackageID_WADApackages 
"-1"
if (isset(
$_GET['packageID'])) { 
  
$ParampackageID_WADApackages = (get_magic_quotes_gpc()) ? $_GET['packageID'] : addslashes($_GET['packageID']); 

$ParamSessionpackageID_WADApackages "-1"
if (isset(
$_SESSION['WADA_Insert_packages'])) { 
  
$ParamSessionpackageID_WADApackages = (get_magic_quotes_gpc()) ? $_SESSION['WADA_Insert_packages'] : addslashes($_SESSION['WADA_Insert_packages']); 

$ParampackageID2_WADApackages "-1"
if (isset(
$_GET['packageID'])) { 
  
$ParampackageID2_WADApackages = (get_magic_quotes_gpc()) ? $_GET['packageID'] : addslashes($_GET['packageID']); 

mysql_select_db($database_connPackages$connPackages); 
$query_WADApackages sprintf("SELECT packageID, package, costperpax, duration, baselocation, category, dateadded, agerange, hotel, educational_tours, field_trips, corporate_outings, plant_visits, budget_package, rollingtours, teambuilding, description, offer FROM packages WHERE packageID = %s OR ( -1= %s AND packageID= %s)"GetSQLValueString($ParampackageID_WADApackages"int"),GetSQLValueString($ParampackageID2_WADApackages"int"),GetSQLValueString($ParamSessionpackageID_WADApackages"int")); 
$WADApackages mysql_query($query_WADApackages$connPackages) or die(mysql_error()); 
$row_WADApackages mysql_fetch_assoc($WADApackages); 
$totalRows_WADApackages mysql_num_rows($WADApackages); 

$colname_educationalDestinations "1"
if (isset(
$_GET['PackageID'])) { 
  
$colname_educationalDestinations = (get_magic_quotes_gpc()) ? packageID addslashes(packageID); 

mysql_select_db($database_connPackages$connPackages); 
$query_educationalDestinations sprintf("SELECT * FROM destinations INNER JOIN (packages INNER JOIN packagedestinations ON packages.packageID = packagedestinations.packageID) ON destinations.destinationID = packagedestinations.destinationID WHERE packages.packageID = %s ORDER BY destination ASC"GetSQLValueString($colname_educationalDestinations"int")); 
$educationalDestinations mysql_query($query_educationalDestinations$connPackages) or die(mysql_error()); 
$row_educationalDestinations mysql_fetch_assoc($educationalDestinations); 
$totalRows_educationalDestinations mysql_num_rows($educationalDestinations); 
?>



And where I'm trying to display the destinations themselves, I have :

<table>
<tr>
<td>Destinations :</td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_educationalDestinations['destination']; ?></td>
</tr>
<?php } while ($row_educationalDestinations = mysql_fetch_assoc($educationalDestinations)); ?>
</table>



If anyone could have a quick look and help me out that would be much appreciated - not sure if its my SQL at the top, or the PHP in the page, but either way it would be good to get it working.

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

Content

rating

Layout

rating

Ease of use

rating

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