0
I’m wanting to list the last record of the table and display, but I’m not getting.
The Reports table has the field Registration date Duration and destination_id
registration date time duration destination_id
2501 2014-03-22 08:25:00 00:40:00(timestamp) SBGL
2501 2015-07-25 10:03:00 00:40:00(timestamp) SBRJ
5531 2015-09-15 19:24:00 00:40:00(timestamp) SBSM
5531 2015-10-19 10:15:00 00:40:00(timestamp) SBBR
I want to show the last destination_id for Registration 2501 and 5531. That is to show that:
2501 => SBRJ
5531 => SBBR
In the code below it returns:
2501 => SBGL
5531 => SBSM
Someone helps pf?
$hours = mysql_query("SELECT SEC_TO_TIME( SUM( TIME_TO_SEC( duration ) ) ) AS duration_sum FROM reports GROUP BY registration");
$regist = mysql_query("SELECT registration AS regist FROM reports GROUP BY registration");
$model = mysql_query("SELECT equipment AS model FROM reports GROUP BY registration");
$base = mysql_query("SELECT destination_id FROM reports");
while($row = mysql_fetch_array($hours) AND $row2 = mysql_fetch_array($regist) AND $row3 = mysql_fetch_array($model) AND $row4 = mysql_fetch_array($base)){
<tr>
<td align="center"><div align="left"><? echo($row3['model']); ?></div></td>
<td align="center"><div align="left"><? echo($row2['regist']); ?></div></td>
<td align="center"><div align="center"><? echo($row['duration_sum']); ?></div></td>
<td align="center"><div align="center"><? echo($row4['destination_id']); ?></div></td>
</tr>
<?php
}//while
The result is perfect, but as I write the line:
– Alexandre Gomes
while ($Row = mysql_fetch_assoc($result) ){
– Alexandre Gomes
got thanks!!!
– Alexandre Gomes