vikaspa Posted March 18, 2009 Share Posted March 18, 2009 visit http://bhavbandh.com/admin/subscriber_search1.php this is matrimonial web site and search is not working properly give height range as 5 to 5.5 following query is executed SELECT * FROM data1 WHERE ( height >=5 and height <= 5.5) order by surname, firstname which I feel is correct however the reult is not correct I found following entry erroneous G01457 Nevalkar Mihir 32930621/ 9323211402 [email protected] Groom 27 Yrs. 1981-11-19 5.11 Gautam Before concluding pls let me tell you that data was originally in excel sheet and height was specified as 5'05" 6'01" 5'11" 5'10" 5'08" 5'11" 5'10" 5'04" 5'11" 5'06" I derived height as follow : (height is stored in data[21] ) list($ft, $in) = split('[\"\']',$data[21]); $height= $ft+($in/100) ; and filed is defined as height decimal(10,2) Yes NULL please help me to reolve this Link to comment https://forums.phpfreaks.com/topic/150018-search-on-range-of-heights-not-working/ Share on other sites More sharing options...
Aeglos Posted March 18, 2009 Share Posted March 18, 2009 The script is working as intended, you have to realize that converting foot/inches height into decimals does not work that well. 5'11" to decimal is 5.11 which is clearly lower than 5.5 and higher than 5.0 Possible solutions would be creating two separate columns in the DB, one for feet and one for inches and sort by feet then inches. Or a more ugly approach is check if the $in variable is less than 10, and in that case divide it by 1000 rather than by 100. Not too sure about that though... You'd have to re-format them again when displaying them. Link to comment https://forums.phpfreaks.com/topic/150018-search-on-range-of-heights-not-working/#findComment-787867 Share on other sites More sharing options...
lonewolf217 Posted March 18, 2009 Share Posted March 18, 2009 why not just change it to $height= $ft+($in/12) ; Link to comment https://forums.phpfreaks.com/topic/150018-search-on-range-of-heights-not-working/#findComment-787881 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.