I have four texts fields in my form that i need them to be inserted into my database,but the four fields are optional to either they should all be filled or just part of them,my problem is that in case the user just fills the two fields and leaves the other two empty,then the filled data should be inserted into mysql and the other blank fields should not be inserted.
This is what i have.
Artist:<input type="text" name="artist" />
Artist:<input type="text" name="artist1" />
Artist:<input type="text" name="artist2" />
Artist:<input type="text" name="artist3" />
//my php code
$sql="INSERT INTO artists (name) VALUES ('$artist'),('$artist1'),('$artist2'),('$artist3')";
mysql_query($sql);
but whenever i run this query it inserts all the four fields.Any help please. And is it relevant to use artist,artist1,artist2,artist3 in the four artist fields or i can just use maybe artist[] for the name part of all the four artist's fields i have?