mysql - PHP - Change value y,n in database -
i try change value y , n, input in database , database got problem, please me solve it. here code
<label>get sponsored <span style="color:red">*</span></label> <select style="width:100px;" class="form-control" name="sponsor"> <?php $generic = array('no', 'yes'); for($i=0;$i<count($generic);$i++){ ?> <option value="<?php echo ($i); ?>" <?php echo (isset($row))?(($row->is_get_sponsored ='y'== 1)?"selected":""):"";?>> <?php echo $generic[$i];?> </option> <?php } ?> </option> </select>
hope need this.
<?php $row->is_sponsored_by = 'y';//already stored value $dropdnarr = array('y' => 'yes', 'n' => 'no');//say y & n storing db , yes & no display echo "selected value ={$row->is_sponsored_by}<br/>"; ?> <label>get sponsored <span style="color:red">*</span></label> <select style="width:100px;" class="form-control" name="sponsor"> <?php foreach ($dropdnarr $key => $value) {?> <option value="<?php echo $key;?>" <?php echo (isset($row)) ? (($row->is_sponsored_by == $key) ? "selected" : "") : "";?> > <?php echo $value;?> </option> <?php } ?> </select>
Comments
Post a Comment