php - How to write a string variable inside mysql query? -
i want implement query :
if(x=1){ $update = "close = '$date'"; } else { $update = "open = '$date'"; } $query = "update table1 set $update id=100"; mysql_query($query);
but got error, mysql can't execute query ?
<?php if($x==1){ $update = "close = '".$date."'"; } else { $update = "open = '".$date."'"; } $query = "update table1 set $update id=100"; mysql_query($query); ?>
Comments
Post a Comment