Something like this should work for you:
// Query the table to get the fields in it
$getfields = mysql_query("SHOW FIELDS FROM yourtablenamehere");
// Create an array to dump all of the field names into
$fieldsarray = array();
// Fill the array with the field names
while($gotfields = mysql_fetch_array($getfields)){
$fieldsarray[] = $gotfields[0];
}
// Check to see if the result of the array search is an integer (The numeric Key value in the array is returned if the search finds a match, and if it doesn't, it returns false.)
If(is_integer(array_search('searchstring', $fieldsarray))){
// Put your code in here to just add the data.
} else {
// Put your code in here to add the field and enter the data.
}
You could just run a while loop and do the check that way too instead of loading it all into a separate array. It's up to you, but this should give you a start to figuring it out.