MySQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsDatabasesMySQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old September 15th, 2013, 06:10 PM
tetontrekker tetontrekker is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2013
Posts: 2 tetontrekker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 25 m 59 sec
Reputation Power: 0
Help with JOIN syntax please

Hello, I've been struggling with JOINs and I hope I found the right forum for help. I teach myself PHP & MySQL so sometimes I don't use the correct terms which can be problematic. PHP I have a firm grip of but I'm very new at MySQL, I'm learning one process at a time an writing it to different pages and queries so I'm fully understanding what I'm doing, then moving on. I am stuck on JOINS I've looked at several examples but cant get my results to print what I want. I have spent all day on this and am very frustrated with myself. It didn't seem that hard.

I have a MS access DB I created several years ago, it houses a Community Band's music library. It's hard to share and novice computer users get overwhelmed and will not use it. It makes more sense to have it on line, I found a driver and am able to export directly to a MySQL DB on our web space, it saves me loads of time and allows me to actively use the Access DB while I'm designing the on line version and learn the code that makes it work. It's working out nicely.

The DB has several tables If I could just get one JOIN to work I could figure out the rest. I am using LEFT JOIN, I have many null values but still need the record to show. I tried several variations but with each one the Arranger ID will only show, not the name. I THINK I'm close but I'm missing something and can figure it out. Here is the page of results http://jhcband.org/wordpress/jhcb-mdb/jhcb-ascabreporting.php

Code:
$tbl_jhcb_ml = "JHCB_Music_Library";
$tbl_arranger_last = "Arrangers";

//Fetching from the database table.
$query = "
	SELECT lib.MusicID, lib.Title, lib.Composer,lib.Composers,lib.Arrangers, ar.ID, ar.FirstName, ar.LastName
	FROM $tbl_jhcb_ml AS lib
	LEFT JOIN $tbl_arranger_last AS ar
	ON lib.Arrangers=ar.LastName
	"
	.$orderBy
	;
$result = mysql_query($query);

if ($result) {
while($row = mysql_fetch_array($result)) {
$catalog = $row["MusicID"]; //need for link to details
$name = $row["Title"];
$composer = $row["Composer"]; //free hand, need to work out of page
$composerfirst = $row["Composers"]; 
$composerlast = $row["Composer"]; 
$arrangerfirst = $row["Arrangers"]; //once I can get it to work I will use alias to get this to display the first name
$arrangerlast = $row["Arrangers"]; 


echo "
    <tr>
    <td><a href=\"jhcbmldb-mdetail.php?mlid=$catalog\">$name</a></td>
    <td>$composerfirst</td>
    <td>$composerlast</td>
	<td>$arrangerfirst</td>
	<td>$arrangerlast</td>
	<td>Jackson Hole Community Band</td>
	<td></td>
	<td></td>
	<td></td>
	<td></td>
 	</tr>";
}
}


ANY help is appreciated.
Thank You
Jule

Reply With Quote
  #2  
Old September 17th, 2013, 02:38 PM
tetontrekker tetontrekker is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2013
Posts: 2 tetontrekker User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 25 m 59 sec
Reputation Power: 0
Never mind, the code is doing exactly what I told it to do. I found my blunder. Thank You for your time

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMySQL Development > Help with JOIN syntax please


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.

© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap