denny911 Posted September 22, 2007 Share Posted September 22, 2007 Hi,i have sort of Yellow Pages for companies integrated on my future site. Visitors have the option of listing them by alphabet.so i have this array: $arr = array('0-9','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'); i managed to make the letters work, but i have no idea how to make that "0-9" part to work when the company name begins with any number from 0 to 9.mySql query looks like this: $result = " SELECT * FROM $ktg, tbl_korisnici WHERE d_id LIKE '%".$djelatnost."'AND f_grad LIKE '$grad%' AND [b]f_ime LIKE '$slovo%'[/b] AND tbl_firme.k_id = tbl_korisnici.k_idORDER BY f_istaknuto DESC, f_ime "; text in bold is the part where the array's element is involved.so, i suppose i need to use a regular expression, but i just dont know where to start!please, help!Denis K. Link to comment Share on other sites More sharing options...
denny911 Posted September 22, 2007 Author Share Posted September 22, 2007 c'mon people, i can't believe nobody's able to help me here.. Link to comment Share on other sites More sharing options...
zppblood Posted September 22, 2007 Share Posted September 22, 2007 EDIT: My solution probably wouldn't have worked so I will come up with a new one.EDIT 2: Use the if/else conditionals to check if the value of the element is 0-9, and change the SQL by that. Link to comment Share on other sites More sharing options...
justsomeguy Posted September 24, 2007 Share Posted September 24, 2007 http://dev.mysql.com/doc/refman/5.0/en/regexp.htmlYou can use a regular expression in the where clause.... AND f_ime REGEXP '^[0-9]' ...would find things that start with a digit. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.