如何使用mysql php从数据库中检索表值

时间:2014-04-30 05:03:15

标签: php mysql ajax

我将三个表连接到一个编辑所有的表。现在我将检索以特定字母开头的所有4个值,但是显示所有带不同字母的开头的值。
             

    include "config.php";
    $term = strip_tags(substr($_POST['searchit'],0,100));
    $term = mysql_real_escape_string($term); 
    if($term=="")
    echo "Enter Something to search";
    else{
    $query = mysql_query("select distinct videoname,category,name,email from edit_all
        where videoname like '$term%' or category like '$term%' or name like '$term%' or email like '$term%'limit 1") or die(mysql_error());

    $string= '';

    if (mysql_num_rows($query))
    {
    while($row = mysql_fetch_assoc($query)){
    $string .= "<b><a href='#'>".$row['videoname']."</a></b> -<br> ";
    $string .= $row['category']."-<br>";
    $string .= $row['name']."-<br>";
    $string .= $row['email']."-<br>";
    $string .= "\n";
    }
    }
    else{
    $string = "No matches found!";
    }
    echo $string;
    }
    ?>

0 个答案:

没有答案