#!/usr/bin/php 0){ echo "The following key values are used in conference #$confid1, but not conference #$confid2:\n"; echo implode(', ', $keyDiff) . "\n"; }else{ echo "conference #$confid2 has all of the key values used in conference #$confid1 in table $tableName.\n"; } $keyDiff = array_diff($keys2, $keys1); if(count($keyDiff) > 0){ echo "The following key values are used in conference #$confid2, but not conference #$confid1:\n"; echo implode(', ', $keyDiff) . "\n"; }else{ echo "conference #$confid1 has all of the key values used in conference #$confid2 in table $tableName.\n"; } // now show if any of the records have different field values in the same key index if(count($fields) > 0){ $saidMessage = false; $commonkeys = array_intersect($keys1, $keys2); $numfields = count($fields); foreach($commonkeys as $key){ $badFields = array(); for($n = 0; $n < $numfields; $n++){ if($data1[$key][$fields[$n]] != $data2[$key][$fields[$n]]){ $badFields[] = $fields[$n]; } } if(count($badFields) > 0){ if(!$saidMessage){ echo "The following records have different values for the same keys:\n"; $saidMessage = true; } echo "$key : "; foreach($badFields as $fieldName){ echo "$fieldName: ({$data1[$key][$fieldName]} != {$data2[$key][$fieldName]}) "; } echo "\n"; } } if(!$saidMessage){ echo "All common key names have matching values for these two sets.\n"; } } } function selectDat($tableName, $selection, $keys, $confid){ $query = "SELECT `" . implode('`,`', $selection) . "` FROM $tableName WHERE conferences_id = $confid"; $q = mysql_query($query); $data = array(); if(mysql_error() != ''){ echo "$query\n" . mysql_error() . "\n"; print_r(debug_backtrace()); } while($row = mysql_fetch_assoc($q)){ $keyVals = array(); foreach($keys as $k){ $keyVals[] = $row[$k]; unset($row[$k]); } $data[implode(':', $keyVals)] = $row; } return $data; }