Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

152
Visualizações
I would like to add a search box by date.to my table using mysql php

I have a table associated with a database mysql, All I want is to add a search box by date.

Although I have tried many methods, but unfortunately all of them did not work for me as I should This is my code:

<form action="" method="GET"">
    <input type="date" name="search" class="form-control" placeholder="Start"  >
    <button type="submit" class="btn btn-primary">Search</button>
</form>
function getRecords($params)
{
    $rp = isset($params['rowCount']) ? $params['rowCount'] : 10;

    if (isset($params['current'])) {
        $page = $params['current'];
    } else {
        $page = 1;
    }
    $start_from = ($page - 1) * $rp;

    $sql = $sqlRec = $sqlTot = $where = '';

    if (!empty($params['searchPhrase'])) {
        $where .= " WHERE ";
        $where .= " ( fullname LIKE '" . $params['searchPhrase'] . "%' ";
        $where .= " OR email LIKE '" . $params['searchPhrase'] . "%' ";

        $where .= " OR phone LIKE '" . $params['searchPhrase'] . "%' )";
    }

    if (!empty($params['sort'])) {
        $where .= " ORDER By " . key($params['sort']) . ' ' . current($params['sort']) . " ";
    }
    // getting total number records without any search
    $sql = "SELECT * FROM `api` where  DATE_FORMAT(created_at, '%Y-%m-%d') = DATE_SUB(CURRENT_DATE(),INTERVAL 1 DAY)";
    $sqlTot .= $sql;
    $sqlRec .= $sql;

    //concatenate search sql if value exist
    if (isset($where) && $where != '') {
        $sqlTot .= $where;
        $sqlRec .= $where;
    }
    if ($rp != -1)
        $sqlRec .= " LIMIT " . $start_from . "," . $rp;
}
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda