Good day to all! In general, the case is this: I have a speed field in the table (car speed). Now I need to write code that will pull out of the opponent's base. For example, in which:

  • speed not more than 100 and not less than 90
  • speed 90, 93, 94, 100, 97 if I have 100
  • if, for example, I have 260, then pull out an opponent no more than 260 and no less than 250: for example, 253, 260, 258, etc.

I think you understand! Please, help!

  • @Romych, According to the rules of the forum, questions should not be reduced to solving or completing student assignments. Please clarify what you have done yourself and what did not work out. - Artem
  • @ Romaich, Please correct grammatical errors and place commas correctly. - Nicolas Chabanovsky

2 answers 2

Finished a bit:

 $speed = $_POST['speed']; // получаем значение скорости $result = mysql_query("SELECT id FROM users_speed WHERE speed BETWEEN '$speed' AND '$speed'-10 ") 
  • with syntax trouble. - Artem
  • corrected ... - Artyomich
  • No, I did not fix it. :) I see it is not clear where a piece of code is taken that will never work! I save for memory> $ speed = $ POST _ ('speed'); // get the speed value> $ result = mysql_query ("SELECT id FROM users_speed WHERE speed> BETWEEN '$ speed' AND '$ speed'-10") - Artem
  • one
    Calm down, be correct! - Artyomich
  • I create a separate table ??? - phpoma
  1. Make another speed range table
  2. Dynamically form a request that will select an opponent from the given framework

     select car from table where speed=>нижняя_граница and speed<=верхняя_граница 
  • but could you write code if you can !? - phpoma
  • I wrote the request =) I do not know pkhp - Gorets
  • $ result = mysql_query ("SELECT id FROM users_speed WHERE speed BETWEEN 100 AND 90"); - angers777
  • or $ result = mysql_query ("SELECT id FROM users_speed WHERE speed > '90 'AND speed <' 100 '"); - angers777