cow Posted September 23, 2008 Share Posted September 23, 2008 Hello to all, I have two database tables, which in the first row both contain numbers. I want to use php to find out which numbers from the 2nd table (let's name it k34) is found in the first (that one we will name report) and which numbers are not found in there. Can some one give me any clues? Thank you in advanced. Link to comment https://forums.phpfreaks.com/topic/125428-check-duplicate-numbers-from-two-tables/ Share on other sites More sharing options...
Garethp Posted September 23, 2008 Share Posted September 23, 2008 $k34q = mysql_query("SELECT * FROM k34"); $i = 0; while($Look = mysql_fetch_array($k43q)) { $k43[$i] = $Look['ColumnName']; $i ++; } $Reportq = mysql_query("SELECT * FROM Report"); $i = 0; while($Look = mysql_fetch_array($Reportq)) { $Report[$i] = $Look['ColumnName']; $i ++; } $e = 0; $j = 0; foreach ($k34 as $v) { $i = 0; foreach($Report as $k) { if($k == $v) { $i = 1; } } if($i == 1) { $Found[$e] = $v; $e ++; } else { $Lost[$j] = $v; $j ++; } } echo "Found:<br>"; foreach ($Found as $v) { echo $v . "<br>"; } echo "<br><br>Lost:<br>"; foreach ($Lost as $v) { echo $v . "<br>"; } Simple, long and unoptimized, but it will do Link to comment https://forums.phpfreaks.com/topic/125428-check-duplicate-numbers-from-two-tables/#findComment-648511 Share on other sites More sharing options...
cow Posted September 23, 2008 Author Share Posted September 23, 2008 Will try it later and let you know... Thx by the way Link to comment https://forums.phpfreaks.com/topic/125428-check-duplicate-numbers-from-two-tables/#findComment-648519 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.