Solved

MYSQL result set seems to be multiplied by 6

Posted on 2013-06-26
2
374 Views
Last Modified: 2013-06-26
I have a result set that is displaying information, but is taking my DB content and showing each result 6 times.

I'm sure I'm overlooking something simple.

if(isset($_GET['refID'])) {
	$refID = $_GET['refID'];
	$queryDet = "SELECT tbldeposit.depDate, tbldeposit.depAmnt, tbldeposit.depDesAcct, tbldeposit.depMemo, tbldeposit.depTender, tbldeposit.depLineID, tbldeposit.depBnkID, tbldeposit.depClientID, tbldeposit.depFundSrc FROM tbldeposit, tbldeposittotals WHERE tbldeposit.depLineID = '$refID'";
	$detResult = mysql_query($queryDet) or die(mysql_error());
	
		while ($rowDet = mysql_fetch_assoc($detResult)) {
		$detID = $rowDet['depAmnt'];
		$detRef = $rowDet['depLineID']; 
		
		echo $detID . " " . $detRef . "<br />"; 
	}
}

Open in new window

0
Comment
Question by:axessJosh
2 Comments
 
LVL 41

Accepted Solution

by:
Sharath earned 260 total points
ID: 39279499
Why do you want to join with tbldeposittotals when you are not selecting any data from this table? Also I did not see any JOIN condition between bldeposit, tbldeposittotals tables.
Try this query and see if it is giving duplicates.
if(isset($_GET['refID'])) {
	$refID = $_GET['refID'];
	$queryDet = "SELECT tbldeposit.depDate, tbldeposit.depAmnt, tbldeposit.depDesAcct, tbldeposit.depMemo, tbldeposit.depTender, tbldeposit.depLineID, tbldeposit.depBnkID, tbldeposit.depClientID, tbldeposit.depFundSrc FROM tbldeposit WHERE tbldeposit.depLineID = '$refID'";
	$detResult = mysql_query($queryDet) or die(mysql_error());
	
		while ($rowDet = mysql_fetch_assoc($detResult)) {
		$detID = $rowDet['depAmnt'];
		$detRef = $rowDet['depLineID']; 
		
		echo $detID . " " . $detRef . "<br />"; 
	}
}

Open in new window

0
 
LVL 2

Author Closing Comment

by:axessJosh
ID: 39279505
forgot to remove that second table join when I updated the statement.  Thanks.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question