close ad
WARNING: Do Not Install the DREAMWEAVER CC 2017 or 2018 Update »
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Joinng 2 MySQL tables

Thread began 4/28/2014 4:47 pm by Armen | Last modified 5/06/2014 4:25 pm by Jason Byrnes | 566 views | 12 replies |

Armen

Joinng 2 MySQL tables

Not sure if I'm doing this correctly...

The two tables are Suppliers (houses all suppliers) and delMenu (houses delivery postal codes, fees, etc).

I need to join two tables (suppID is the common filed in both).

I have a recordset (rsDelMenu) that lists all records in delMenu that match two variables posted from the form on the previous page. I now need to merge the results of this recordset with all records in the Suppliers table, where suppID = suppID


=== rsDelMenu ===

$colname_rsDelMenu = "-1";
if (isset($_POST['serviceType'])) {
$colname_rsDelMenu = $_POST['serviceType'];
}
$colPC_rsDelMenu = "-1";
if (isset($_POST['Postal_Code'])) {
$colPC_rsDelMenu = $_POST['Postal_Code'];
}
mysql_select_db($database_connData, $connData);
$query_rsDelMenu = sprintf("SELECT * FROM delMenu WHERE serviceTypeID = %s AND delPC = %s", GetSQLValueString($colname_rsDelMenu, "int"),GetSQLValueString($colPC_rsDelMenu, "int"));
$rsDelMenu = mysql_query($query_rsDelMenu, $connData) or die(mysql_error());
$row_rsDelMenu = mysql_fetch_assoc($rsDelMenu);
$totalRows_rsDelMenu = mysql_num_rows($rsDelMenu);

Sign in to reply to this post

Jason ByrnesWebAssist

see this page for details on creating a sql join query:

http://www.w3schools.com/sql/sql_join.asp

Sign in to reply to this post

Armen

I took a look at the page Jason. Thank you. However, I'm kinda stuck when it comes to filtering the joined tables based on the two variables posted by the form on the previous page...

I'm thinking the easiest thing would be to update this recordset to a Join?

$colname_rsNeo = "-1";
if (isset($_POST['Postal_Code'])) {
$colname_rsNeo = $_POST['Postal_Code'];
}
$colType_rsNeo = "-1";
if (isset($_POST['serviceType'])) {
$colType_rsNeo = $_POST['serviceType'];
}
mysql_select_db($database_connData, $connData);
$query_rsNeo = sprintf("SELECT * FROM delMenu WHERE delPC = %s AND %s = serviceTypeID", GetSQLValueString($colname_rsNeo, "text"),GetSQLValueString($colType_rsNeo, "int"));
$rsNeo = mysql_query($query_rsNeo, $connData) or die(mysql_error());
$row_rsNeo = mysql_fetch_assoc($rsNeo);
$totalRows_rsNeo = mysql_num_rows($rsNeo);

Sign in to reply to this post

Jason ByrnesWebAssist

yes, update the recordset to a join, and do not change anything for the where clause.

Sign in to reply to this post

Armen

Where exactly should I put JOIN code? I keep getting an error...

Sign in to reply to this post

Armen

Never mind. Got it. Thanks, Jason. As always, your help is greatly appreciated!

Sign in to reply to this post

Armen

I have setup a JOIN. However, the filtering does not seem to be working. All records show up...

SELECT *
FROM delMenu INNER JOIN suppliers ON delMenu.suppID=suppliers.suppID
WHERE delPC = colname AND colType = serviceTypeID

========
colname gets runtime value from: $_POST['Postal_Code']
colType gets runtime value from:$_POST['serviceType']

Am I approaching this correctly?

Sign in to reply to this post

Jason ByrnesWebAssist

looks correct, send a copy of the page and a link where i can see the problem.

Sign in to reply to this post

Armen

p/m

Sign in to reply to this post

Armen

It looks like the repeat region might be the issue...???
The same menu seems to be repeating a few times...

Sign in to reply to this post
loading

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