[nycphp-talk] Mysql Selects
Alberto dos Santos
acas at sapo.pt
Tue Jun 21 16:38:09 EDT 2005
Almost there, the correct sintax is as follows:
$query = "SELECT * FROM `organizations` WHERE `org_zip` = '$zips'";
Bye.
--
Alberto dos Santos
-----Original Message-----
From: talk-bounces at lists.nyphp.org [mailto:talk-bounces at lists.nyphp.org] On
Behalf Of harvey
Sent: terça-feira, 21 de Junho de 2005 21:24
To: NYPHP Talk
Subject: [nycphp-talk] Mysql Selects
Hello,
I've got code that queries the 'zipcode' tables in a database and finds the
zips that are within X miles of Y zip code. Works fine.
<?php
$z = new zipcode_class;
$zips = $z->get_zips_in_range($zipcode,$distance);
if (empty($zips))
{ echo "Error: " . $z->last_error; }
else { foreach ($zips as $key => $value) { echo "<b>$key</b>
is
<b>$value</b> miles from <b>$zipcode</b>.<br>"; }; }
?>
Now I want to query the 'organization' tables and return all the orgs that
have one of the zips found above. But I'm not sure how to go about it.
Something like the following (which I know is incorrect)?
SELECT * FROM organizations WHERE org_zip IN ($zips)
Thanks in advance for your help...I'm sure it's some very basic concept I'm
missing.
Harvey
_______________________________________________
New York PHP Talk Mailing List
AMP Technology
Supporting Apache, MySQL and PHP
http://lists.nyphp.org/mailman/listinfo/talk
http://www.nyphp.org
More information about the talk
mailing list