Reputation: 1
Instead of hardcoding query: LIMIT 3, i would like to get LIMIT number different every time i press the button.
That's what I've got so far:
$region=$_GET["region"];
$number=$_GET["limit"];
$con = mysql_connect('localhost') or die(mysql_error());
mysql_select_db('test') or die(mysql_error());
$sql1="SELECT size,price,member FROM buy WHERE region= '".$region."' LIMIT = '".$number."' ORDER BY price DESC "
Error I get is:
Warning: mysql_fetch_array() expects parameter 1 to be resource
So LIMIT is empty
So I got two buttons: one set $number=3 another set $number=10 but I don't know how to put it inside SQL.
So far only option WHERE region= '".$region."'
works.
Any ideas ?
Upvotes: 0
Views: 243
Reputation: 98
A few points here:
Upvotes: 1
Reputation: 2343
First - remove quotes around limit number.
Second, remove =
before number.
Third - move LIMIT after ORDER BY
i think thats all :)
$sql1="SELECT size,price,member FROM buy WHERE region= '".$region."' ORDER BY price DESC LIMIT ".(int) $number
Upvotes: 3