1

I have concatenated three tables to one table that is edit all. Now i'm going to retrieve the all the 4 values that starts with the particular letter, But is displaying all values with starts with different letter.

    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;
    }
    ?>
Marcel Gosselin
  • 4,610
  • 2
  • 31
  • 54
user3422452
  • 57
  • 1
  • 2
  • 5
  • It shouldn't display multiple values since you have a `limit 1` but maybe it's because you haven't left space here `'$term%'limit` – AyB Apr 30 '14 at 05:05
  • You are using mysql_* functions which are now deprecated and will be removed from PHP in the future. So you need to start using MySQLi or PDO instead. – Rakesh Shetty Apr 30 '14 at 05:06
  • refer this abt PDO or mysqli usage instead of mysql_ which is deprecated, http://stackoverflow.com/questions/23332264/echo-issue-with-while-if-else/23332345#23332345 – dev1234 Apr 30 '14 at 05:07
  • is it possible to update the post with you're outputs. – dev1234 Apr 30 '14 at 05:09
  • what do you actually need to do ? – dev1234 Apr 30 '14 at 05:10
  • i need to retrieve the data from database that data should starts with the perticular letter – user3422452 Apr 30 '14 at 06:27

0 Answers0