wordpress - php- getting wrong values while looping -
i making opportunity form have provided update , delete functionality in wordpress. question wrong loop .. getting wrong values i. unable print "$opportunity_exp_date[$i]" if delete single opportunity. might tough understand guys problem. here code.
for($i=count($contact_opportunity);$i>=0;$i--){ //for listing of won opportunities if($contact_opportunity[$i]!='0' && !empty($contact_opportunity[$i])){ ?> <?php if($opportunity_status[$i]=='won'){?> <div class="won-opp"><h3>won</h3></div> <?php echo "<div class='oname'>"."new opportunity '".$contact_opportunity[$i]."' added"."</div>"; ?> <a href="<?php echo admin_url( "admin.php?page=contact_profile&post=$pid&opnm=$contact_opportunity[$i]&opamt=$opportunity_amount[$i]&opedt=$opportunity_exp_date[$i]&opsts=$opportunity_status[$i]&opnt=$opportunity_note[$i]" )?>"><span class="opp-edit" title="edit"></span></a> <span class="btn_remove_opp" title="delete opportunity"></span> <input type="hidden" value="<?php echo $contact_opportunity[$i]?>" class="del_op_nm"> <input type="hidden" value="<?php echo $opportunity_status[$i]?>" class="del_op_sts"> <input type="hidden" value="<?php echo $opportunity_exp_date[$i]?>" class="del_op_exp"> <input type="hidden" value="<?php echo $opportunity_amount[$i]?>" class="del_op_amt"> <input type="hidden" value="<?php echo $opportunity_note[$i]?>" class="del_op_nt"> <div id="opp-list"> <?php echo "<span class='sts'>".$opportunity_status[$i]."</span>"." expected close on ".$opportunity_exp_date[$i]."<br>"; echo $opportunity_amount[$i]." "."<div class='footer-op-nt'>".$opportunity_note[$i]."</div>"."<br>"; ?> </div> <br> <?php } } }
i believe off one; don't use count() in loops slower xd
$count= count($contact_opportunity); for($i=$count-1;$i>=0;--$i){ //for listing of won opportunities
Comments
Post a Comment