Erison Posted August 18, 2013 Share Posted August 18, 2013 (edited) Hello my name is Erison. I'm new here and I'm sure that is not sleep for days. 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 } ?> Edited August 18, 2013 by Erison Quote Link to comment https://forums.phpfreaks.com/topic/281321-view-variable-in-the-same-line-as-the-counter-for/ Share on other sites More sharing options...
gristoi Posted August 19, 2013 Share Posted August 19, 2013 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++; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/281321-view-variable-in-the-same-line-as-the-counter-for/#findComment-1445784 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.