Jude Howell Sarabia
Jude Howell Sarabia

Reputation: 65

How to search query in php?

The error is that the program fails to search keyword.

Here is the following code:

 $query = "SELECT english.word, maranao.word, maranao.pronounciation, maranao.grammar, english.definition" . 
                "FROM english, maranao".
                "WHERE english.keyword_num = maranao.keyword_num and english.word = '$search'";

                $result = mysql_query($query) or die(mysql_error());

                while($row=mysql_fetch_array($result))
                {   
                    echo $row['word'];
                    echo $row['pronounciation'];
                    echo $row['grammar'];
                    echo $row['definition'];
                }

Upvotes: 0

Views: 61

Answers (1)

Saty
Saty

Reputation: 22532

You need space in your WHERE and FROM clause

" FROM english, maranao".

" WHERE english.keyword_num = maranao.keyword_num and english.word = '$search'";

And don't use mysql Why shouldn't I use mysql_* functions in PHP?

Try to learn Prepared statement

Upvotes: 2

Related Questions