搜索引擎有多个关键字

I have a search engine that is working , but only when I search 1 word. Whenever I search multiple keywords I only get 1 result.

Example : In my database I have tags like 'test' and 'hello' ; Whenever I enter "test hello" and click "Search" it displays :

1 result hello (this being the title of the post with the tag = hello).

My code (search.php - the page where I get the search results):

<?php

$button = $_GET ['submit'];
$search = $_GET ['search']; 

if(!$button) {
    echo "you didn't submit a keyword";
} else {
    if(strlen($search)<=1) {
        echo "Search term too short";
    } else {
        echo "You searched for <b>$search</b> <hr size='1'></br>";
        mysql_connect("localhost","root","root");
        mysql_select_db("myschool");

        $search_exploded = explode (" ", $search);

        foreach($search_exploded as $search_each) {
            $x = NULL;
            $construct = NULL;
            $x++;
            if($x==1) {
                $construct .="tag LIKE '%$search_each%'";
            } else {
                $construct .="OR tag LIKE '%$search_each%'";
            }

            $construct ="SELECT * FROM posts WHERE $construct";
            $run = mysql_query($construct);

            $foundnum = mysql_num_rows($run);

            if ($foundnum==0) {
                echo "Sorry, there are no matching result for <b>$search</b>.";
            } else {
                echo "$foundnum results found !<p>";

                while($runrows = mysql_fetch_assoc($run)) {
                    $title = $runrows ['title'];
                    $tag = $runrows ['tag'];

                    echo "<a href='#'><b>$title</b></a><br>";

                }
            }

        }
    }
}
?>

Problem is probably around the $x=++ part , because I believe the engine is not displaying or even searching through all the rows in the database , and not displaying when the num row count > 1 .

Thanks in advance guys.

EDIT :

I now get multiple results with the code above BUT I get them in this form :

You searched for hello test postare

1 results found ! HELLO 1 results found !

Test 1 results found !

postare noua

How can I make it add the results in 1 place , and not say it everytime it finds a new result for a different keyword ?

You need to start $x variable before foreach statement, and dont set it as null if you want to use it as an integer.

The $construct variable has the same error, you must be having the same response for three times, thats because you have to close the foreach statement before calling mysql select.

$x = 1;
$construct = NULL;

foreach($search_exploded as $search_each) 
{ 
    if($x==1) { 
        $construct .="tag LIKE '%$search_each%'"; 
    } else { 
        $construct .="OR tag LIKE '%$search_each%'"; 
    } 
    $x++;
}
$select ="SELECT * FROM posts WHERE $construct";
...

Last Edit

<?php

$button = $_GET ['submit'];
$search = $_GET ['search']; 

if(!$button) {
    echo "you didn't submit a keyword";
} else {
    if(strlen($search)<=1) {
        echo "Search term too short";
    } else {
        echo "You searched for <b>$search</b> <hr size='1'></br>";
        mysql_connect("localhost","root","root");
        mysql_select_db("myschool");

        $search_exploded = explode (" ", $search);
        $x = 1;
        $construct = '';

        foreach($search_exploded as $search_each) {
            if($x==1) {
                $construct .="tag LIKE '%$search_each%'";
            } else {
                $construct .="OR tag LIKE '%$search_each%'";
            }
            $x++;
        }

        $select ="SELECT * FROM posts WHERE $construct";
        $run = mysql_query($select);

        $foundnum = mysql_num_rows($run);

        if ($foundnum==0) {
            echo "Sorry, there are no matching result for <b>$search</b>.";
        } else {
            echo "$foundnum results found !<p>";

            while($runrows = mysql_fetch_assoc($run)) {
                $title = $runrows ['title'];
                $tag = $runrows ['tag'];

                echo "<a href='#'><b>$title</b></a><br>";

            }
        }
    }
}
?>

You have a couple issues on your code. You missed a " on this line:

echo "Sorry, there are no matching result for <b>$search</b>";

And the last else does not have an if