Monday 20 June 2016

Edit Codeigneter


<form method="post" enctype="multipart/form-data">

<?php $row=$this->dbabc->getedit($aaa);?>

<table>
<tr>
<td>Username</td>
<td><input type="text" name="username" value="<?php echo $row->username;?>"></td>
</tr>

<tr>
<td></td>
<td><?php echo form_error('username');?></td>
</tr>

<tr>
<td>Password</td>
<td><input type="text" name="password" value="<?php echo $row->password;?>"></td>
</tr>

<tr>
<td></td>
<td><?php echo form_error('password');?></td>
</tr>


<tr>
<td>Address</td>
<td><input type="text" name="address" value="<?php echo $row->address?>"></td>
</tr>

<tr>
<td></td>
<td><?php echo form_error('address');?></td>
</tr>


<tr>
<td>Contact</td>
<td><input type="text" name="contact" value="<?php echo $row->contact?>"></td>
</tr>

<tr>
<td></td>
<td><?php echo form_error('contact');?></td>
</tr>


<tr>
<td>Email</td>
<td><input type="text" name="email" value="<?php echo $row->email?>"></td>
</tr>

<tr>
<td></td>
<td><?php echo form_error('email');?></td>
</tr>

<tr>
<td>Image</td>
<td>
<input type="hidden" name="old_image" value="<?php echo $row->image;?>">
<input type="file" name="image"><?php echo $row->image;?></td>
</tr>

<tr>
<td></td>
<td><?php echo form_error('image');?></td>
</tr>

<tr>
<td>Gender</td>
<?php
if($row->gender =='male')
{
?>
<td><input type="radio" name="gender" value="male" checked="checked">Male</br>
<input type="radio" name="gender" value="female">Female</td>
<?php
}
else
{
    ?>
    <td><input type="radio" name="gender" value="male" >Male</br>
<input type="radio" name="gender" value="female" checked="checked">Female</td>

    <?php
}
?>
</tr>

<tr>
<td></td>
<td><?php echo form_error('gender');?></td>
</tr>



<tr>
<td>City</td>
<td>
 <select name="city[]" multiple="multiple">

<?php

error_reporting(0);

$hbs=array('surat','nadiad','Baroda');

$exq=explode(',',$row->city);



foreach($hbs as $r)
{
    if($exq[0]==$r || $exq[1]==$r || $exq[2]==$r)
    {
        ?>
     
       <option value="<?php echo $r;?>" selected="selected"><?php echo $r;?>
        <?php
    }
    else
    {
        ?>
       
       <option value="<?php echo $r;?>"> <?php echo $r;?>
        <?php
    }
}

?>
 </select>
</td>

</tr>

<tr>
<td></td>
<td><?php echo form_error('city');?></td>
</tr>

<tr>
<td>Hobby</td>
<td>
<?php

error_reporting(0);

$hb=array('cricket','tennis','football');

$ex=explode(',',$row->hobby);

foreach($hb as $r)
{
    if($ex[0]==$r || $ex[1]==$r || $ex[2]==$r)
    {
        ?>
        <input type="checkbox" name="hobby[]" value="<?php echo $r;?>" checked="checked">
        <?php echo $r;?>
        <?php
    }
    else
    {
        ?>
        <input type="checkbox" name="hobby[]" value="<?php echo $r;?>">
        <?php echo $r;?>
        <?php
    }
}

?>

</td>

</tr>

<tr>
<td></td>
<td><?php echo form_error('hobby');?></td>
</tr>



<tr>
<td><input type="submit"></td>
<td><input type="reset"></td>
</tr>

</table>
</form>

No comments:

Post a Comment