0

这是一个可以在数据库中搜索的程序。但我想搜索 Postcode 和 Huisnummer 列。但我尝试的一切都不起作用。任何人的想法

<!DOCTYPE html>
<html lang="nl">
    <head>
        <meta charset="utf-8">
        <link rel="stylesheet" type="text/css" href="index1.css" />
        <title>Inboedelwaarde op adres</title>
    </head>
    <body>
    <p>
        <form action="zoekadres.php" method="post"> 
        Postcode: <input type="text" name="term" /><br />       
        <input type="submit" name="submit" value="Zoek" />   
        </form>
    </p>
    </body>
</html>


<html lang="nl">
    <head>
        <meta charset="utf-8">
        <title>Inboedelwaarde</title>
    </head>
    <body>  
        <?php      
        mysql_connect ("localhost", "root","")  or die (mysql_error());
        mysql_select_db ("inboedelmeter");
        $term = $_POST['term'];
        $sql = mysql_query("SELECT Postcode, Huisnummer, Toevoeging, Inboedelwaarde 
                            FROM puntentotaal 
                            WHERE Postcode like '%$term%'");
            while ($row = mysql_fetch_array($sql)){  
            echo 'Postcode: '.$row['Postcode'];    
            echo '<br/> Huisnummer: '.$row['Huisnummer'];    
            echo '<br/> Toevoeging: '.$row['Toevoeging'];    
            echo '<br/> Uw inboedelwaarde is EURO € '.$row['Inboedelwaarde'];
            echo '<br/><br/>';
            }
                echo "<p><form action='adresbekijken.php' method='post'>
                        <input type='submit' name='submit' value='Opnieuw zoeken'>"
        ?>
    </body>
</html>

谢谢!

4

2 回答 2

0

尝试这个WHERE Postcode like '%' . $term . '%'");

于 2013-01-30T15:28:23.333 回答
0

在代码上

$sql = mysql_query("SELECT Postcode, Huisnummer, Toevoeging, Inboedelwaarde FROM puntentotaal WHERE Postcode like '%$term%'");

您正在搜索所有字段。尝试将其更改为“SELECT Postcode, Huisnummer WHERE Postcode like '%$term%'”;”。

因此,您将只搜索该列。

于 2013-01-30T15:36:34.313 回答