## STEP 3 - Validate the contents of each row
$sql = "SELECT * FROM ihcsecure.csv_import";
$result = mysql_query($sql,$link1) or die(mysql_error());
$rcount = mysql_num_rows($result);
echo '<br/><br/>There are now '.$rcount.' rows of data in the csv_import table.<br/>';
$i = 0;
while ($records = mysql_fetch_array($result)) {
$i = $i+1;
$dmpo_id = $records['group_id'];
$type = $records['type'];
echo '<br/>The DMPO ID for row '.$i.' is '.$dmpo_id;
if (isValid($type) > 0){
echo 'The type code is valid';
}else {
echo 'The type code is not valid';
}
}
function isValid($cType){
$sqlx = "SELECT * FROM carecards.nbi_types where type = '$cType'";
$types = mysql_query($sqlx,$link2) or die(mysql_error());
$vType = mysql_num_rows($types);
return $vtype;
}
|