Jump to content

Archived

This topic is now archived and is closed to further replies.

turbocueca

Can't search MySQL DB

Recommended Posts

[b]A code that works:[/b]

[code]<form method="POST" action="">
Search Word: <input type="text" name="query">
<input type="SUBMIT" value="Search!">
</form>

<?
include 'db.php';
if (isset($_POST['query'])) {
$result = mysql_query("SELECT name,system FROM usbextreme WHERE name LIKE '%$query%'") or die (mysql_error());

while(list($column1, $column2)=mysql_fetch_array($result)){

echo "Result: $column1, $column2 <br />";
}

}
?>[/code]

[b]My code:[/b]

[code]<form method="POST" action="">
Search:<input type="text" name="query">
<input type="SUBMIT" value="Search!">
</form>
<?php    if (isset($_POST['query']))
        {
        include 'db.php';
        $execute=mysql_query("SELECT name,system,work_status,postedby,comments FROM usbextreme WHERE name LIKE '%query%'") or die (mysql_error());
        while (list($name,$sys,$stat,$user,$comment)=mysql_fetch_array($execute))
        {
        echo "$name   $sys   $stat   $user   $comment";
        }
        } else
        {
        echo "You didn't press the button!";
        }
?>[/code]


Can someone please tell me what's wrong with my code, 'cause it doesn't search anything.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.