elseif in php code is not working -
this php code. else if statement not working. please help me.thanks in advance.
if($row=mysql_fetch_array($result1,mysql_assoc)){ $pv=$row['pv']; $cv=$row['cv']; if($pv=="first_name"){ $sql1="update user set fname='$cv' id='$id'"; $result1=mysql_query($sql1); }elseif($pv=="lastname"){ $sql1="update user set lname='$cv' id='$id'"; $result1=mysql_query($sql1); } }
your code looks okay rid of elseif
if($row=mysql_fetch_array($result1,mysql_assoc)){ $cv=$row['cv']; $column="fname"; if($row['pv']=="lastname"){ $column="lname"; } $sql1="update user set $column='$cv' id='$id'"; $result1=mysql_query($sql1); }
php
No comments:
Post a Comment