views:

22

answers:

3

This is my html:

<select name="results"> 
    <option value="0">Vis alle</option> 
    <option value="10">10 resultater per side</option> 
    <option value="20">20 resultater per side</option> 
    <option value="30">30 resultater per side</option> 
    <option value="40">40 resultater per side</option> 
    <option value="50">50 resultater per side</option> 
    <option value="75">75 resultater per side</option> 
    <option value="100">100 resultater per side</option> 
</select>

When the topmost option is selected and form submitted, the get variable "results" disappears from the URL. I've tried switching out the 0 with strings "*" and "x" to no avail.

Thanks for any explanations and solutions.

A: 

Hmm, did you try -1?

elsni
A: 

A value of zero will get interpreted as "nothing" and therefore disappear from your $_GET. But that should be no problem in your case. You could also just test of the "results" is in the array to check if someone wants to see all. Or you change the zero to the string "all" and test for that.

if (!isset($_GET['results']) {
    //logic for building your query without a LIMIT
}
Tim
A: 
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>Your HTML5!</title>
    <?php
        if(isset($_GET['submit'])){
            echo $_GET['results'];
        }
    ?>
</head>
<body>
<form action="thisfile.php" method="GET">
<select name="results"> 
    <option value="0">Vis alle</option> 
    <option value="10">10 resultater per side</option> 
    <option value="20">20 resultater per side</option> 
    <option value="30">30 resultater per side</option> 
    <option value="40">40 resultater per side</option> 
    <option value="50">50 resultater per side</option> 
    <option value="75">75 resultater per side</option> 
    <option value="100">100 resultater per side</option> 
</select>
<input type="submit" value="submit" name="submit"/>
</form>


</body>
</html>

Are you trying like this? If yes then it seems to work on my local.

Meher Ranjan