ballhogjoni Posted October 11, 2008 Share Posted October 11, 2008 I have a database full of ip ranges like 221.134.0.0. I am trying to search the database for this based off the user ip address. My query is simple: $oDB->Select('ip_tracking','ip','WHERE ip LIKE "%'.$ip.'%"'); first param is the table name, second is what I want, third is the where clause. Link to comment https://forums.phpfreaks.com/topic/127977-solved-search-a-database-via-like/ Share on other sites More sharing options...
budimir Posted October 11, 2008 Share Posted October 11, 2008 And your problem is...?? Link to comment https://forums.phpfreaks.com/topic/127977-solved-search-a-database-via-like/#findComment-662709 Share on other sites More sharing options...
ballhogjoni Posted October 11, 2008 Author Share Posted October 11, 2008 it doesn't find the ip range. Link to comment https://forums.phpfreaks.com/topic/127977-solved-search-a-database-via-like/#findComment-662747 Share on other sites More sharing options...
CroNiX Posted October 11, 2008 Share Posted October 11, 2008 so you want it to find 221.134.* ? Link to comment https://forums.phpfreaks.com/topic/127977-solved-search-a-database-via-like/#findComment-662750 Share on other sites More sharing options...
ballhogjoni Posted October 11, 2008 Author Share Posted October 11, 2008 Thats correct. Link to comment https://forums.phpfreaks.com/topic/127977-solved-search-a-database-via-like/#findComment-662756 Share on other sites More sharing options...
CroNiX Posted October 11, 2008 Share Posted October 11, 2008 Maybe this? <?php $exip = explode('.',$ip); $newIP=$exip[0].'.'.$exip[1].'.'; $oDB->Select('ip_tracking','ip',"WHERE ip LIKE '$newIP%'"); Link to comment https://forums.phpfreaks.com/topic/127977-solved-search-a-database-via-like/#findComment-662763 Share on other sites More sharing options...
ballhogjoni Posted October 11, 2008 Author Share Posted October 11, 2008 perfect...thanks Link to comment https://forums.phpfreaks.com/topic/127977-solved-search-a-database-via-like/#findComment-662771 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.