Jump to content

View variable in the same line as the counter for


Erison

Recommended Posts

Hello my name is Erison. I'm new here and I'm sure that is not sleep for days. :sweat:

I want that number in the variable $parcelaX be displayed only when equal to $i of loop "for".

 

can someone help me? Please ...

 

below my code:

<?php
for($i = 1; $i <= $parcelas; $i++){					
?>
							
<div><?php echo $i ?></div>				

<div>
<?php 						
while($arrParcelas = mysql_fetch_array($sqlParcelas)){
					
$dataX		 = $arrParcelas['dataPagamento'];
$parcelasX   = $arrParcelas['parcelaPaga'];
$valorX		 = $arrParcelas['valorPago'];
							
	if($i == $parcelasX)
	{
		echo  $parcelasX  . " - " . $valorX . " <br /> ";
	}					
?>
</div>
<?php } ?>		

try:

<div>
<?php 
$i = 0;						
while($arrParcelas = mysql_fetch_array($sqlParcelas)){
					
$dataX		 = $arrParcelas['dataPagamento'];
$parcelasX   = $arrParcelas['parcelaPaga'];
$valorX		 = $arrParcelas['valorPago'];
							
	if($i == $parcelasX)
	{
		echo  $parcelasX  . " - " . $valorX . " <br /> ";
	}					
?>
</div>
<?php $i++; } ?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.