I'm struggling building a SQL query from the output of a form, i.e. the user inputs into a form which in turn decides the query.
I have never done this before and was just wondering if anyone had any links tutorials of something like this!? I have searched but haven't found anything too useful yet.
Basically all I want to do is for the user to pick from a drop down menu how they want a leaderboard displayed, i.e. top 50 results, bottom 50, 50 to 100 results, etc.
Do I just tie a complete SQL statement with the corresponding LIMIT info inside to a variable. The variable being the value of the chosen item in the drop down menu.
Pseudocode as follows;
If chosen value = A
then SQL= this
ELSE IF chosen value = B
then SQL=this
ELSE IF chosen value =C
then SQL=this
else
SQL statement without any LIMIT.
Sorry if that sounded confused. I know it's only basic stuff but I'd really like to see an example of it in action.
By the way I am using PHP and MySQL.
Thanks.
I have never done this before and was just wondering if anyone had any links tutorials of something like this!? I have searched but haven't found anything too useful yet.
Basically all I want to do is for the user to pick from a drop down menu how they want a leaderboard displayed, i.e. top 50 results, bottom 50, 50 to 100 results, etc.
Do I just tie a complete SQL statement with the corresponding LIMIT info inside to a variable. The variable being the value of the chosen item in the drop down menu.
Pseudocode as follows;
If chosen value = A
then SQL= this
ELSE IF chosen value = B
then SQL=this
ELSE IF chosen value =C
then SQL=this
else
SQL statement without any LIMIT.
Sorry if that sounded confused. I know it's only basic stuff but I'd really like to see an example of it in action.
By the way I am using PHP and MySQL.
Thanks.