Hello... First I should explain what is wrong. I have a database with a table called subs... Within this table I have a unique field called ID, then a fields called member, date(unix timestamp) amount, month, year...
HOWEVER for each month and year there is several entries all with different date stamps. How can I extract the entry with the most recent date??? However there is a catch. I want to view payments made since a certain date but only one per month... Below is my code... I thnk I need to add or change something slightly but i am fairly new to PHP and am totally stuck...
MANY THANKS IN ADVANCE!!!
[code=php:0]$query="SELECT * FROM records WHERE section='B' OR section='C' OR section='S' order by section, surname";
$result=mysql_query($query);
for ($row=0;$row<mysql_num_rows($result);$row++){
$forename=mysql_result($result,$row,'forename');
$surname=mysql_result($result,$row,'surname');
$id=mysql_result($result,$row,'id');
$ref="19nx".$id.substr($forename,0,2).substr($surname,0,2);
$section=mysql_result($result,$row,'section');
$giftAid=mysql_result($result,$row,'giftAid');
if ($giftAid>1){$day=date('d',$giftAid);$month=date('m',$giftAid);$year=date('y',$giftAid);}else{$day="";$month="";$year="";}
$giftAidName=mysql_result($result,$row,'giftAidName');
$giftAidComment=mysql_result($result,$row,'giftAidComment');
$subdate=mktime(0,0,0,$submonth,$subday,$subyear);
$query="SELECT * FROM subs WHERE member='$id' AND date>$subdate Order BY id DESC";
$subResult=mysql_query($query);
$subs="";
for($ss=0;$ss<mysql_num_rows($subResult);$ss++){
$amount=mysql_result($subResult,$ss,'amount');
if ($amount==""){$amount='25';}
$date=date("M/Y",mysql_result($subResult,$ss,'date'));
$subs=$subs."<a title='$date' alt='$date'>$amount</a>,";
}
[/code]
This outputs a line of results which is right except it shows 2 or 3 for april, 3 or 4 for may anthoer 2 or 3 for june etc... I hope someone gets my drift!