Forum Moderators: coopster
Kind of like this:
$sql = mysql_query("SELECT products_model FROM products") or die("Invalid query: " . mysql_error());
$result = mysql_query($sql);
$handle = fopen("http://www.123456789.com/inventory.txt", "r");
while(!feof( $handle ) )
{
$file =fgets( $handle );
$values = explode("\n", $file);
$resp = in_array('$values[0]', $result););
if ($resp) {//do nothing }
else {
echo "$values[0]<br>";
}
}
fclose( $handle );
I know this is way wrong, just need a good push in the right direction.
then do such trick:
$sql = "SELECT products_model FROM products WHERE products_model IN ('" . implode(", ", $in_file) ."')";//this will give results that are in db
//get the results into an array
//$result = array("1234");//that's in db
$difference = array_diff($in_file, $result);
//$difference is 5678, 56963
Hope this sets you on right track. The only problem may be getting the in_file array.
Best regards
Michal Cibor
$stack = array("Start");
$data = array ("Start");
$handle = fopen("http://www.123456789.net/inventory.txt", "r");
while(!feof( $handle ) )
{
$file =fgets( $handle );
$values = explode(",", $file);
array_push($stack, $values[0]);
}
$sql = "SELECT products_model FROM products";
$query = mysql_query($sql);
while ($result = mysql_fetch_array($query)) {
array_push($data, $result[0]);
}
$difference = array_diff($stack, $data);
while (list(, $value) = each($difference)) {
echo "New Item: $value<br />\n";
}
fclose( $handle );
mysql_close($link);
Thanks again for all the help!