dbrimlow Posted March 22, 2006 Share Posted March 22, 2006 I have two tables that are exactly the same in stucture. table 1 gets populated by an auto dump sent via a custom 3rd party inhouse application. It works fine for 90% of our tables, but for one table the application is limited ... so I created a manual table to allow showing the same array as all the others.table 2 is manually populated, to provide data in fields not usually included in table 1 dump.I then have 2 sets of arrays that search both tables for the same content, and defines how it should display on the page in a description and in a bulleted amenities list. eg: Table1 select includes -if ($myrow[coop] == "COOPERATIVE") { $description .= ", COOP"; $building[]="Cooperative"; } if ($myrow[coop] == "CONDOMINIUM") { $description .= ", CONDO"; $building[]="Condominium"; } if ($myrow[coop] == "CONDOP") { $description .= ", CONDOP"; $building[]="Cond-Op";} etc., etc.Table2 select includes: if ($mytownhouse[bldg_type] == "townhouse") { $description .= ", TOWNHOUSE"; $building[]="Townhouse";} if($mytownhouse[bldg_type] == "brownstone") { $description .= ", BROWNSTONE"; $building[]="Brownstone";} etc., etc.This worked fine for the first year or so, it would provide data missing in table 1 with data from table 2.But now, after a recent upgrade of our custom app., the dump is including some of the data that was missing from table1. So now, I am getting duplicate amenities.These conditional arrays are both HUGE lines of text - easily spanning over 800 lines of code.What I want know, is if there is an EASY way for me to exclude any duplicates among the tables from displaying, and set one table as the default source in the event of a duplicate? I can compare each and every field and if both have data, ignore one or the other, but there MUST be a simple tables wide compare statement. Something like:if (($myrow[$building()] !="") && ($mytownhouse[$building()] !="") { $building()=$mytownhouse [$building()];}I don't know if I explained this coherently or not, and I don't think the above would work.Dave Quote Link to comment https://forums.phpfreaks.com/topic/5513-2-tables-wsame-fields-compare/ Share on other sites More sharing options...
wickning1 Posted March 22, 2006 Share Posted March 22, 2006 Ideally this should be done in the MySQL query, but I don't know enough about your system to write it for you. It sounds like you are doing things the hard way - bigtime.You could probably solve your problem quickly with the PHP function array_unique(), but again from your description I'm not clear on what you're after. Quote Link to comment https://forums.phpfreaks.com/topic/5513-2-tables-wsame-fields-compare/#findComment-19760 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.