NameSilo

How can I filter the results?

Spaceship Spaceship
Watch

Mr Blockeel

Established Member
Impact
2
in a autocomplete function i use this mysql code

$query = "SELECT Gemeente, Postcode FROM tekoop WHERE Gemeente LIKE '$queryString%' LIMIT 10";

but there are more then one of the same entries, for example there's 4 times 'Gent' en 3 times 'Genk'
so if i type in 'Gen' 7 results will show up ( 4 times Gent en 3 times Genk )
know i want the script to return Gent only one time and Genk only one time,
otherwise said, returning data should only show up onc

anyone know how to do this?
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Unstoppable DomainsUnstoppable Domains
Code:
$query = "SELECT [COLOR=Blue]DISTINCT [/COLOR]Gemeente, Postcode FROM tekoop WHERE Gemeente LIKE '$queryString%' LIMIT 10";
 
0
•••
Thx

now this is resolved i got another problem i don't know how to solve

i try to make a real estate search for a friend of me,
but one of the search criteria is the type of building (apartment, villa, ...) now you have to be able to select more then one of them. But that's not the problem, if you select more then one then (if i use the get-methode) there is smeting like results?php?type=villa&type=apartment. because the last overrides the first only the apartments wil show up if i use a mysql command to call them from the database using the $type-variable....

someone any idea how to solve this?
 
0
•••
instead of putting type=villa&type=apartment, try making the variables pass like: type=villa|apartment

or some unique char to split it, and then use explode function on $type and explode it by the | or whatever, and then when making the mysql query, make it loop through the $type array (foreach) and use `type`='$type[$key]' OR `type`='$type[$key]' etc
 
0
•••
Use the following HTML code to present a multiple selection to the visitor:

Code:
<select name="types[]" multiple="multiple">
        <option>apartment</option>
        <option>villa</option>
</select>

Then use the following PHP code to read the results:

Code:
<?php
$typeQuery = '';
if (isset($_REQUEST['types']))
{
    foreach ($_REQUEST['types'] as $type)
    {
        if ($typeQuery != '')
        {
            $typeQuery .= " OR ";
        }
        $typeQuery .= "type='".mysql_real_escape_string($type)."'";
    }
    if ($typeQuery != '')
    {
        $query = "SELECT Gemeente, Postcode FROM tekoop WHERE $typeQuery LIMIT 10";
    }
}

?>
 
0
•••
Dynadot — .com Registration $8.99Dynadot — .com Registration $8.99

We're social

Domain Recover
DomainEasy — Zero Commission
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back