RE: [PHP-DB] RE: Further MySQL query problems...
| From: | Bastien Koert | Date: | Mon, 28 Mar 2005 17:13:02 +0000 |
| Subject: | RE: [PHP-DB] RE: Further MySQL query problems... | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-39056@lists.php.net to get a copy of this message | ||
why wouldn't you just run a query to return only the elements that you want?
Bastien
From: "NIPP, SCOTT V (SBCSI)" <sn4265@sbc.com> To: <php-db@lists.php.net> Subject: [PHP-DB] RE: Further MySQL query problems... Date: Mon, 28 Mar 2005 10:49:24 -0600 Oops... Correction to the last line of the script. <?php } while ($blah = mysql_fetch_array($exclude_results)); ?> Should be...<?php } while ($blah = array_shift($temp)); ?>Scott Nipp Phone: (214) 858-1289 E-mail: sn4265@sbc.com Web: http:\\ldsa.sbcld.sbc.com -----Original Message----- From: NIPP, SCOTT V (SBCSI) Sent: Monday, March 28, 2005 10:47 AM To: 'php-db@lists.php.net' Subject: Further MySQL query problems... I am having trouble in the following code. Basically, I want to query two separate database tables and then generate an array from these two queries. The first query will return a list of ALL systems. The second query will return a list of systems that should be excluded. The problem is that this is getting me nowhere. Here is the pertinent code... $query = "SELECT CPU_Hostname FROM AllMid_Data WHERE CPU_IN_SVC = \"Y\" AND CPU_DNS = \"sbcld.sbc.com\" ORDER BY CPU_Hostname ASC"; $results = mysql_query($query, $Prod) or die(mysql_error()); $system = mysql_fetch_array($results, MYSQL_NUM); $exclude_query = "SELECT hostname FROM exclusion"; $exclude_results = mysql_query($exclude_query, $Prod); $exclude = mysql_fetch_array($exclude_results, MYSQL_NUM); $temp = array_diff($system, $exclude);<?php do {$sys = $blah[0]; echo "<tr>"; ?> <?php echo $sys; ?><?php echo "</tr>"; } ?> <?php } while ($blah = mysql_fetch_array($exclude_results)); ?>I have cut out a lot of extraneous stuff that I don't think is pertinent. Please let me know if you see something causing my problems. The first query table has about 900 entries and the query returns about 90 hostnames. The exclude table query has only 13 hostnames and obviously returns all. I am looking for a way to display the approximately 77 entries that are NOT in the exclude table. Thanks again. Scott Nipp Phone: (214) 858-1289 E-mail: sn4265@sbc.com Web: http:\\ldsa.sbcld.sbc.com -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php