Re: [PHP] [Followup] Exploding Zip Codes! (Using PHP's explode function)

2002-08-15 Thread Analysis & Solutions

On Tue, Aug 13, 2002 at 12:13:35PM -0700, Keith Posehn wrote:
> 
> I have the code together now to put it all the zip codes into and array--but
> now I need to add those zip codes to a sql statement for the WHERE clause.
> 
> SELECT * FROM [table]
> WHERE zip="[all the darn zips listed here]"

$query = "... WHERE zip IN ('" . implode("','", $ZipArray) . "')";

--Dan

-- 
   PHP classes that make web design easier
SQL Solution  |   Layout Solution   |  Form Solution
sqlsolution.info  | layoutsolution.info |  formsolution.info
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] [Followup] Exploding Zip Codes! (Using PHP's explode function)

2002-08-13 Thread Michael Geier

are you trying to insert into MySQL DB?  Or select out of the DB?

insert:
table structure:
zip
city
etc...

connect to db;
loop through your array {   //while ($array = array_shift($data))
create $sql from array parts
  ($sql = "insert into table (zip,city) values
('".$array[0]."','".$array[1]."');
$result = mysql_exec($sql,$db);
}

select:
connect to db;
$sql = "select from table where zip = '".[insert query here]."'";
$result = mysql_exec($sql,$db);

.m

> -Original Message-
> From: Keith Posehn [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, August 13, 2002 2:14 PM
> To: [EMAIL PROTECTED]
> Subject: [PHP] [Followup] Exploding Zip Codes! (Using PHP's explode
> function)
>
>
> Final question on this (I hope).
>
> I have the code together now to put it all the zip codes into and
> array--but
> now I need to add those zip codes to a sql statement for the WHERE clause.
> Example:
>
> SELECT * FROM [table]
> WHERE zip="[all the darn zips listed here]"
>
> (or something like that)
>
> How would I set it to loop all the zip codes into this statement? I'm not
> worried about the SQL syntax, I can figure that out without a problem, but
> the php code is the question. This is in MySQL btw, and I have looked
> through the docs there and at php for this, but need some help
> from all you
> guru's out there.
>
> Thanks for the help!
>
> (Previous message here)
>
> > I have a huge block of zip codes I need to seperate into their
> constituent
> > parts for a query of a database. The block looks like this (in part):
> >
> > |  36310  ABBEVILLE  |
> > |  35440  ABERNANT  |
> > |  35005  ADAMSVILLE  |
> > |  35540  ADDISON  |
> > |  35006  ADGER  |
> > |  35441  AKRON  |
> >
> > I need to use eplode (probably) to seperate this all out into
> two arrays,
> > one of codes, the other of names--presumably named $zips[] and $cities[]
> > with the rest of the data dumped.
> >
> > I have gone and looked at the various functions docs at
> php.net, but they
> > haven't really helped to answer my question as much as I would like. Any
> > information is appreciated.
> >
> > Thanks
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php