So I have a php script that integrates with an api to scrap information from json results. The tool does a search query of say all profiles that are located in a certain state, it then saves all the returned links and begins looping over them and executing them one at a time to view the data inside and retrieve the desired data. At the end of this process I'm trying to have it write the results into my database. Say I'm gathering $firstname and $lastname, when the tool runs I notice it never misses any information but often it write entries in the database with repeat information of maybe just $firstname but not $lastname. When it does this it will write that entry twice, once with all the information and another time with just the partial information. Considering it always no matter what gathers what I need I'm trying to figure out an if or else statement or some other kind of trigger so before it writes to my table the php script will check to make sure all of the available fields are populated with information. If they are it writes, if not it just does nothing.
Here's what I have so far..
if($firstname = ""){
echo ""; }
else {
$sql_S = "INSERT INTO records (firstname, lastname, email, phone, duns, cage, expirationdate, businessname, address, city, state, zip, naics) VALUES ('{$firstname}','{$lastname}','{$email}','{$phone}','{$duns}','{$cage}','{$expirationDate}','{$businessName}','{$samAddress}','{$samCity}','{$samState}','{$samZip}','{$naics_num}')";
$res_CE = mysql_query($sql_S);
}
It doesn't seem to work and further more I can't get it to check multiple fields such as $firstname,$lastname.
Any input is greatly appreciated.
Thank you for your time.