GD77 Posted May 29, 2013 Share Posted May 29, 2013 Hello: I m having this foreach duplicated in returned data this happened when I upgraded to a news version of xammp and can t figure out why the duplicated are taking place... <?php if(isset($sess_uLOG) && $sess_uLOG==true) { $attrib = array('name'=>'fxxx','class' => 'fxxx'); echo form_open('main/profile',$attrib); ?> <ul class="cont_up"><!-- START section Overview--> <?php foreach ($u_profile as $u_pr) : ?> <li> <div class="sec_topic">Overview<span><?php $ubtn=array('name'=>'form_btn','value'=>'btn_save0','type'=>'submit','content'=>'Save');echo form_button($ubtn)?></span></div> <div class="profile_pic"> <img src="<?php echo base_url()."assests/imgs/profile/thumbs/".$u_pr->prof_pic; ?>" width="200" height="200" alt="<?php echo $u_pr->un; ?>"> </div> <div class="sec_content0"> <blockquote> <span>gender:</span><span> <SELECT name="ugender"> <?php @$u_gender=$this->input->post('ugender', TRUE); foreach ($ar_gender as $val_gender) { if ($u_gender != NULL && !empty($u_gender)) { echo "<option value='$val_gender'"; if ($val_gender == $u_gender) {echo " selected='selected'";} echo ">".$val_gender."</option>\n"; } else { echo "<option value='$val_gender'"; if ($val_gender == $u_pr->gender) {echo " selected='selected'";} echo ">".$val_gender."</option>\n"; }//END if else post } ?> </SELECT> <span>name:</span> <span> <input type="text" name="ufname" value="<?php echo isset($_POST['ufname']) ? $_POST['ufname'] : $u_pr->ufn; ?>" maxlength="12"> <input type="text" name="ulname" value="<?php echo isset($_POST['ulname']) ? $_POST['ulname'] : $u_pr->uln; ?>" maxlength="12"> </span> <span>username:</span> <span><input type="text" name="uname" value="<?php echo isset($_POST['uname']) ? $_POST['uname'] : $u_pr->un; ?>" maxlength="18"></span> <span>country:</span><span> <SELECT name="ucountry"> <?php @$u_count=$this->input->post('ucountry'); foreach ($country as $value) { if ($u_count != NULL && !empty($u_count)) { echo "<option value='$value'"; if ($value == $u_count) {echo " selected='selected'";} echo ">".$value."</option>\n"; } else { echo "<option value='$value'"; if ($value == $u_pr->u_country) {echo " selected='selected'";} echo ">".$value."</option>\n"; }//END if else post } ?> </SELECT> </span> <span>phone: +</span><span><input type="text" name="uphone" value="<?php echo isset($_POST['uphone']) ? $_POST['uphone'] : $u_pr->u_phone; ?>" maxlength="18"></span> </blockquote> </div> </li> <?php endforeach; ?> </ul><!-- END section Overview--> <?php echo form_close(); }else{ .... } Quote Link to comment https://forums.phpfreaks.com/topic/278544-codeigniter-foreach-loops-duplicates/ Share on other sites More sharing options...
trq Posted May 29, 2013 Share Posted May 29, 2013 Nothing relating to any foreach has changed between any update. Quote Link to comment https://forums.phpfreaks.com/topic/278544-codeigniter-foreach-loops-duplicates/#findComment-1432918 Share on other sites More sharing options...
GD77 Posted May 29, 2013 Author Share Posted May 29, 2013 any suggestions why i m having the duplicated results? Quote Link to comment https://forums.phpfreaks.com/topic/278544-codeigniter-foreach-loops-duplicates/#findComment-1432919 Share on other sites More sharing options...
trq Posted May 29, 2013 Share Posted May 29, 2013 Nope. You haven't specified what is being duplicated and your code makes for very hard reading. Quote Link to comment https://forums.phpfreaks.com/topic/278544-codeigniter-foreach-loops-duplicates/#findComment-1432923 Share on other sites More sharing options...
GD77 Posted May 29, 2013 Author Share Posted May 29, 2013 the <ul> </ul> and content being duplicated so i m having 2 identical results Quote Link to comment https://forums.phpfreaks.com/topic/278544-codeigniter-foreach-loops-duplicates/#findComment-1432927 Share on other sites More sharing options...
Solution GD77 Posted May 29, 2013 Author Solution Share Posted May 29, 2013 Fixed the problem was in the Model query I had to use LEFT JOIN on 2 tables don't know why I forgot to fix that before... Quote Link to comment https://forums.phpfreaks.com/topic/278544-codeigniter-foreach-loops-duplicates/#findComment-1432951 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.