PHP MySQL Update query
Posted
by Jordan Pagaduan
on Stack Overflow
See other posts from Stack Overflow
or by Jordan Pagaduan
Published on 2010-06-02T00:22:56Z
Indexed on
2010/06/02
0:33 UTC
Read the original article
Hit count: 692
I have a website that has an update query. Example.
Table name -> myTable Table Content -> id(AI) name --> myName age --> 13 image --> (no values) birthdate --> (no values)
I only put values in name and age. In image and birthdate, I haven't put anything.
If I edit it and update it and I don't put anything in name and in age, I only put values in image and in birthdate. The output is like this. (This ouput I wanted)
Table name -> myTable Table Content -> id(AI) name --> myName age --> 13 image --> myImage.jpg birthdate --> Feb. 31, 2010
This is my code:
<?php //mysql connect... //mysql select database... $sql = "UPDATE myTable SET name = '".$name."', age = '".$age."', image = '".$image."', birthdate"'$birthdate.."' WHERE id = $id"; mysql_query($sql); ?>
I used this code but the output is:
Table name -> myTable Table Content -> id(AI) name --> (no values) age --> (no values) image --> myImage.jpg birthdate --> Feb. 31, 2010
Feel free to ask if you don't understand my question
Thank you
© Stack Overflow or respective owner