Web Hosting
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WordPress Search don’t return error

Discussion in 'Misc WordPress Requests' started by Carlos.souza10, Oct 30, 2017.

  1. Carlos.souza10


    Search don’t return error, by Carlos.souza10

    Personal, I have this search form for a page in wordpress, but it has 2 problems:
    1- When loading the page, it lists all the data in the table. I need it to start blank
    2- When I look for a term that does not exist in the database, it does not return the error message and is blank.
    When I look for a term that already exists, it works correctly.

    <title>Receive Form</title>
    <form method=”post” >
    Your Name:<br />
    <input type=”text” name=”nome” />
    <input type=”submit” value=”Search” />

    $nome = $_POST[‘nome’];

    if (is_user_logged_in()):

    global $wpdb;

    $customers = $wpdb->get_results(“SELECT * FROM wp_clientes where Nome_Cliente LIKE ‘%”.$nome.”%’ “);

    if($customers >= 1){
    echo “<table>”;
    foreach($customers as $customer){
    echo “<tr>”;
    echo “<td>”.$customer->Nome_Cliente.”</td>”;
    echo “<td>”.$customer->Email_Proprietario.”</td>”;
    echo “<td>”.$customer->Nome_Empresa.”</td>”;
    echo “<td>”.$customer->Pagamentos.”</td>”;
    echo “</tr>”;
    echo “</table>”;
    } else {
    echo “Nothing!”;
    echo “Sorry, only registered users can view this information”;


    Search don’t return error

Share This Page

Web Hosting