Jump to content

codeigniter foreach loops duplicates


GD77
Go to solution Solved by GD77,

Recommended Posts

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{
	....
}
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.