Good day! Please tell me how to set a custom variable for the number of lines output from mysql There are -

$query="SELECT nam3 , COUNT(*) AS total FROM lottoindex WHERE nam3 > 0 GROUP BY nam3 ORDER BY nam3+ 0 ASC "; 

You need to add LIMIT "myvar" Where "myvar" is the number that the user entered in the input ... Thank you very much in advance

  • Not quite clear what the complexity. Get the number that the user entered turns out? If so, just add "LIMIT X" to $ query. - T.Zagidullin

1 answer 1

 $query="SELECT nam3 , COUNT(*) AS total FROM lottoindex WHERE nam3 > 0 GROUP BY nam3 ORDER BY nam3+ 0 ASC"; if (isset($_GET['count'] && is_numeric($_GET['count'])){ $query .= ' LIMIT '.$_GET['count']; } 

where is html

 <input name="count"> 
  • And humanly? - Qwertiy
  • LIMIT $ myvar is the principle and is written in the question of how to transfer the value from the input so that it would output the necessary number of lines - Жека
  • Edited answer - Anton Shchyrov
  • @ Anton Shchyrov 500 error - Zheka