943,724 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 834
  • PHP RSS
Jun 8th, 2009
0

don't print duplicate records

Expand Post »
Hi, I am working on result.php page, where I want to order data by date, but I want remove (don't print) duplicate records.I am using 3 tables:
1,results - short res
2,excercises - short exc
3,user - shor usr

I have this query:

<div class="main">
		<table cellspacing="20">
			<tr>
			<th></th>
			<th></th>
			<th>Number of good excercises</th>
			<th>Number of bad excercises</th>
			<th>Effecient</th>
			</tr>
<?php 
$query1="SELECT DATE_FORMAT(res_time, '%D %M %Y') AS res_time, exc_excercise_name, res_result FROM res INNER JOIN exc ON res_exc_id=exc_id  WHERE res_usr_id=$_GET[id] GROUP BY res_time HAVING COUNT( res_time) = 1";
		$result1 = mysql_query($query1);
while (list($res_time,$exc_excercise_name,$res_result) = mysql_fetch_row($result1)) {
    		echo "<tr>",
			"<td class='time'>",
			$res_time,"</td>",
			"</tr>",
			"<tr>",
			"<td>",
			"</td>",
            "<td class='font'>",
            $exc_excercise_name,"</td>",
            "<td>",
            "</td>",
			"<td>",
            "</td>",
            "<td class='result'>",
            $res_result,"%","</td>",
        "</tr>";
		   
}
@mysql_close($connect);
			?>
			
		</table>
		<hr />	
</div> 
But this query doesn't work and print only half of records.
Could somebody help me?

Thanks
Last edited by Tekmaven; Jun 8th, 2009 at 4:41 pm. Reason: Code Tags
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
raul66 is offline Offline
10 posts
since May 2009
Jun 8th, 2009
0

Re: don't print duplicate records

SELECT DISTINCT DATE_FORMAT
Reputation Points: 10
Solved Threads: 9
Junior Poster
VIeditorlover is offline Offline
137 posts
since Dec 2007
Jun 8th, 2009
0

Re: don't print duplicate records

SELECT DISTINCT DATE_FORMAT
it doesn't work...
Reputation Points: 10
Solved Threads: 0
Newbie Poster
raul66 is offline Offline
10 posts
since May 2009
Jun 8th, 2009
0

Re: don't print duplicate records

Click to Expand / Collapse  Quote originally posted by raul66 ...
it doesn't work...
GROUP BY uses column_list having same order and same number used with SELECT statement.

PHP Syntax (Toggle Plain Text)
  1. SELECT
  2. DATE_FORMAT(res_time, '%D %M %Y') AS res_time,
  3. exc_excercise_name, res_result
  4. FROM res INNER JOIN exc ON res_exc_id=exc_id WHERE
  5. res_usr_id='value'
  6. GROUP BY
  7. DATE_FORMAT(res_time, '%D %M %Y') AS res_time,
  8. exc_excercise_name, res_result
  9. HAVING COUNT
  10. (DATE_FORMAT(res_time, '%D %M %Y')) = 'value'
Moderator
Reputation Points: 2136
Solved Threads: 1228
Posting Genius
adatapost is offline Offline
6,527 posts
since Oct 2008
Jun 8th, 2009
0

Re: don't print duplicate records

Click to Expand / Collapse  Quote originally posted by adatapost ...
GROUP BY uses column_list having same order and same number used with SELECT statement.

PHP Syntax (Toggle Plain Text)
  1. SELECT
  2. DATE_FORMAT(res_time, '%D %M %Y') AS res_time,
  3. exc_excercise_name, res_result
  4. FROM res INNER JOIN exc ON res_exc_id=exc_id WHERE
  5. res_usr_id='value'
  6. GROUP BY
  7. DATE_FORMAT(res_time, '%D %M %Y') AS res_time,
  8. exc_excercise_name, res_result
  9. HAVING COUNT
  10. (DATE_FORMAT(res_time, '%D %M %Y')) = 'value'
what do you mean with 'value'?....
res_usr_id='value' - here I want obtain ID of user,who I click on other page, therefore was there res_usr_id=$_GET[id] and it works.
(DATE_FORMAT(res_time, '%D %M %Y')) = 'value' - here I want eliminate duplicate date records and therefore was there (DATE_FORMAT(res_time, '%D %M %Y')) = '1'.

Is it ok?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
raul66 is offline Offline
10 posts
since May 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Retrieving the size of a rotated image
Next Thread in PHP Forum Timeline: Help with php script to export mysql data and import data





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC