Solved

MYSQL result set seems to be multiplied by 6

Posted on 2013-06-26
2
376 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

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

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
The viewer will learn how to dynamically set the form action using jQuery.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

691 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