theladycoder Posted June 27, 2008 Share Posted June 27, 2008 I am fairly new to PHP and I am not sure where to start. I need to perform a calculation based on user input. For example: You should be able to type in any value in the inside diameter or cross sectional diameter boxes. For example 1.4332”. The computer will look at this as an inch dimension and also a metric dimension. It will find all inside diameters from the standard and metric o-ring database that are within ¼” of this dimension. Then the customer will type in the cross sectional diameter they desire. This time the computer will only search from the first list of inside diameters that it came up with and match all the ones that have that inside diameter and a cross section that is within 1/32” of what the customer typed in. That will give the customer a final list to choose from. They will pick one or more from the list. I am not sure how to go about this and would greatly appreciate any help! Link to comment https://forums.phpfreaks.com/topic/112130-solved-oring-measurements/ Share on other sites More sharing options...
Barand Posted June 27, 2008 Share Posted June 27, 2008 Use a query something like SELECT id, diameter, description FROM oring WHERE ABS(diameter - $inchesInput) <= 0.25 The dropdowns themselves can be generated using AJAX (See sample in my sig) Link to comment https://forums.phpfreaks.com/topic/112130-solved-oring-measurements/#findComment-575750 Share on other sites More sharing options...
theladycoder Posted July 1, 2008 Author Share Posted July 1, 2008 Okay, this is what I am trying to: Let's say that $var is = to .040 (which this is in inches) $var = @$_GET['q']; $trimmed = trim($var) <= 0.25; I want to take that value and display all values in the same table from the CS field that is within .25 either way using the query $query = "select * from tablename where csInches >= $trimmed"; The problem is that I am not returning anything and I would like to display within 1/4" of the user input. What am I doing wrong? Thanks :-\ Link to comment https://forums.phpfreaks.com/topic/112130-solved-oring-measurements/#findComment-579439 Share on other sites More sharing options...
Barand Posted July 1, 2008 Share Posted July 1, 2008 $trimmmed will contain "true" or "false" depending on whether $var is greater then 0.25 or not. Link to comment https://forums.phpfreaks.com/topic/112130-solved-oring-measurements/#findComment-579561 Share on other sites More sharing options...
theladycoder Posted July 2, 2008 Author Share Posted July 2, 2008 I do appreciate the help, but are you saying that I should not use trim in this case? Have I written the code wrong? Again, thanks. Link to comment https://forums.phpfreaks.com/topic/112130-solved-oring-measurements/#findComment-580089 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.