Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Querying MySQL to search for array data
- Michael Whittaker
August 6, 2004, 9:01 am
rate this thread
I have a problem with my php script.
The script's task is to search an IP-Database with ranges as entries
and find, in which range the entered IP is.
OK, I've queried the MySQL-Results of the ranges into an array,
"IP ==> internalid"
where internalid is the Primarykey of the table from which I can get
more infomation about that range at a later point.
The IP can be found in a range and so on.. Everythong works. But: How
can I search the database for more than one entry, when the IP exists
in more than one range?
I really don't know how to do that, maybe my energy is nearly at "0"
now, so it would be very nice, if you could help me =)
Greetings, Michael Whittaker.
Re: Re: Querying MySQL to search for array data
> firstname.lastname@example.org (Michael Whittaker) wrote in message
> > The IP can be found in a range and so on.. Everythong works. But:
> > can I search the database for more than one entry, when the IP
> > in more than one range?
> Use a simple OR clause:
> SELECT * FROM the_table
> WHERE IP [condition 1] OR IP [condition 2];
And just in case you donít know, you can use the LIKE to search for
partial ip matches. See mysql manual for LIKE.
http://www.dbForumz.com / This article was posted by author's request
Articles individually checked for conformance to usenet standards
Visit Topic URL to contact author (reg. req'd). Report abuse:
Re: Querying MySQL to search for array data
Thanks for you replies!
The IPs are already stored in integer format... But one question btw:
Does php generate negative integers too? Or does the ip2long-function
start with "0"?
I'll try the OR and LIKE-queries tomorrow and will tell you if it
solved my problem :)