0

Hi. Assume there are contents in DB as follows.

------------------------
name favorites
John cat
Peter dog
-------------------------

If as soon as I enter "John Peter" the following screen should display with no page movement.

Input: John Peter

Output:
:The favorites:
John cat
Peter dog

Is it possible to impliment? Give me some advice please. Thanks

Edited by buranda: n/a

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by as.bhanuprakash
0

Is this the code your after

<?php
if (isset($_POST) && !empty($_POST)) {
    $words=explode(' ',$_POST['name']);
    $sql='SELECT * FROM `table` WHERE';
    foreach ($words AS $word) {
        $sql.=' `name`="'.mysql_real_escape_string($word).'" OR';
        }
    $sql=substr($sql,0,-3);
    $r=mysql_query($sql) or die($sql.'<hr>'.mysql_error());
    while ($row=mysql_fetch_array($r) {
        echo $row[0].'------'.$row[1].'<br>';
        }
    }
?>
0

"With no page movement" --- If you meant that the result should be displayed without the page submission, then you will have to use ajax.
For more insight on how to work on Ajax, take a look at the following link
http://w3schools.com/ajax/default.asp

Hi. Assume there are contents in DB as follows.

------------------------
name favorites
John cat
Peter dog
-------------------------

If as soon as I enter "John Peter" the following screen should display with no page movement.

Input: John Peter

Output:
:The favorites:
John cat
Peter dog

Is it possible to impliment? Give me some advice please. Thanks

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.