Jump to content

halfsparrow

Members
  • Posts

    24
  • Joined

  • Last visited

Everything posted by halfsparrow

  1. This is not helping me to store value in variable, What i want is for eg lets take 2nd query where gpm match and ewt does not. so ffor that i will get 2 values for totcool so i want to store that in variable where totcool1 = xxxx and totcool2 = xxxx OR The method you show gives me array i have attached the ss of it, so basically what want is the value of totcool from array[0] should be stored in variable totcool1 and the value of totcool from array[1] should be stored in totcool2
  2. there's no mathematical connectio between them. it the value that is universally proven and i have a excel sheet for it
  3. No, such data is not possible. If gpm is increasing ewt will also follows the same trend, lets forget about the case when bpth are not present i will write it down myself, can you just provide me with the other query I can make query for neither case myself by referring to query you will provide me for when either of the gpm or ewt matches
  4. yeah but the issue here will be i will have to hard code for every value for gpm, because the uniluxmodel we are using here is the name of table and i have total 15 tables and the difference between each gpm varies according to table and its not something that follows a particular trend. So the best query will be the one that @Psycho suggested.
  5. oh now i got it, So what i want is if, Gpm is 1.75 and ewt is 45 then i want totcool value for: 1) The record with lower value for gpm and lower value for ewt. for this example, totcool for 1.5 gpm and 40 ewt 2) The record with higher value for gpm and higher value for ewt. for this example, totcool for 2.0 gpm and 50 ewt And for @Barand solution, i appreciate his solution but i am in search of solution that does not require me to create another table, because i just have upload a small snippet of my database,it is really large and i will not be able to create a range table for that many entries.
  6. By lower i meant next lowest, and by higher i meant next highest, so for example if ewt is anywhere between 30-40, lets say 36 then lowest ewt should be 30 and highest ewt should be 40. We can get this by using max and min statement, like select * from table where ewt =(select max ewt from table where ewt<entered ewt) : this is for the lower ewt . so its like GPM LOWER GPM HIGHER GPM 1.2 1 1.25 1.3 1.25 1.5 Same for EWT EWT LOWER EWT HIGHER EWT 35 30 40 38 30 40 46 40 50 Hope it makes clear now
  7. If user enters gpm, = 1.75 and ewt as 35 i will have to do calculation for totCool for 1.5 gpm and 2 gpm and 30 and 40 ewt Basically the value below and the value above
  8. This looks perfect to me but just a few changes instead of getting getting average in query i want simple query to select * from table and then will do maths in if statement, also for when neither records are matched can you help me with query, i want that query to be treated same as before like when we did'nt found gpm we took one value below or above it so same way we want one value up and one value down for both gpm and ewt
  9. 1) If neither GPM or EWR match any records in that case i will do average of both of them, also i dont want average in query i will execute query and then add maths in that by saving the things i want in a variable 2) It will not be possible as user will never enter value that low or that high, to clear things out it is a real world situation web page where GPM is gallons per minute and ewt is entering water temperature so user will only enter from desired range
  10. i Cant do this, because user will also demand to enter value that are not in the database
  11. Count thing counts the number of column fetched that helped me to determine how many columns are fetched and can do further calc
  12. $commandCount = "SELECT COUNT(*) as 'countRow' from {$uniluxModel} where gpm = {$uniluxGpm} OR ewt = {$uniluxEwt}"; $command = "SELECT * from {$uniluxModel} where gpm = {$uniluxGpm} AND ewt = {$uniluxEwt}"; echo " Command is ".$command; $stmtCount = $dbConn->prepare($commandCount); $exeOkCount = $stmtCount->execute(); //print_r($stmt->fetchColumn()); $stmt = $dbConn->prepare($command); $exeOk = $stmt->execute(); if ($stmtCount->fetchColumn() == 1) { echo "inside"; if($exeOk){ echo "<br>"; while ($row = $stmt->fetch()){ echo "gpm is : " .$row['gpm'] ." "." ewt is " .$row['ewt'] ." "."<br> tot cool is " .$row['totCool']. "<br>" ; } } else echo "error executing query"; } else{ echo "Not Found!"; } it gives me correct result just not show me which one is not found. suppose i enter 1.75 and 30 i t shows me not found directly i just want that it shows me that gpm is not found or ewt is not found or both are not found
  13. What happens for or statement is If i enter 1 for gpm and 50 for ewt it shows only gpm is found as it will find gpm first and stop processing afterwards
  14. Okay so basically, i am working on a webpage where there is form and user will enter value accordingly. i have 2 fields that is GPM and EWT where user will enter value of their choice now i have a database which looks like the picture i have attached. Now if user enters 1 for gpm and 30 ewt its simple because its in the database, i will simply fetch totCool and print it out but if user enters 1.75 for gpm and 30 for ewt i will have to take average of totCool for 1.5 and 2 for 30 ewt because 1.75 is not in the table similarly if user enters 1.5 for gpm and 35 for ewt i will have to take average of totCool for 30 and 40 for 1.5 gpm because 35 is not in the table Similarly if user enters 1.75 and 35 i will have to take average for both and calculate SO the question here how can i know that database cannot find gpm or ewt or both Hope this helps to understand you guys
  15. No what i want is if query finds both the value then i need to print out values from database, if query finds only gpm and ewt is not present then i will have to interpolate ewt, similarly if ewt is found and gpm is not found then i need to interolate values for gpm. i have everyhing figured out. just confused about how to determine which value is not obtained by the query
  16. I have tried using OR but the issue is if both are correct it won't return me the value for both, so it doesn't work as well
  17. That's not giving me errors so its fine, i am just confused about the solution. also i am not using mssqli i am using PDO
  18. I have a php code SQL QUERY GOES LIKE $command = "SELECT * from {$uniluxModel} where gpm = {$uniluxGpm} AND ewt = {$uniluxEwt}"; where uniluxGpm and uniluxEwt are the variable user will enter in the form. i have a database where there are certain values for gpm and certain values for ewt For example gpm has value ranging from 1-5 with difference of 0.5 eg: 1,1.5,2,2.5 etc and ewt has values ranging from 30-100 with differerence of 10 eg: 30,40,50 so if users enters gpm = 1 and ewt as 30 it returns me values from databse but if user enters gpm =1.75 and ewt as 30 it returns me not found How can i know that database did'nt found gpm and it found ewt Thanks in advance
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.