I would like to display the 2nd record in a $row.
Here is my query
select LEFT(A.F_ANOTRIMESTRE, 4) Year,
RIGHT(A.F_ANOTRIMESTRE, 2) Quarter,
IF(RIGHT(A.F_ANOTRIMESTRE, 2)=03,'Enero a Marzo',
IF(RIGHT(A.F_ANOTRIMESTRE, 2)=06,'Abril a Junio',
IF(RIGHT(A.F_ANOTRIMESTRE, 2)=09,'Julio a Septiembre',
IF(RIGHT(A.F_ANOTRIMESTRE, 2)=12,'Octubre a Diciembre',
'')
))) Quarter_Name,
ROUND(A.POR_RENTABILIDAD, 2) Quarterly_yield
from dr_rent_carteras_trimestres A
where A.ID_CARTERA = $ID_CARTERA
And A.IND_RENTABILIDAD = 1
Order by A.F_ANOTRIMESTRE asc
Here is the php.
while($row = mysql_fetch_array($result))
{
$currentState = ($currentState == 'odd' ? 'even' :'odd' );
echo "<tr id='centered' >"; echo "<td class='leftalign'>" . $row['Quarter_Name'] . "</td>";
echo "<td>" . $row['Quarterly_yield'] . "</td>";
echo "</tr>";
}
echo "</tbody></table>";
I want to pull the 2nd record in Quarterly_yield. How would I display that?
If you want to do it from PHP, you can just index your results, like you do any other array.
Alternatively, you can do this from MySQL by using LIMIT 1,1 at the end of your query. For instance, here’s your modified query. Notice the last line: