Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

173
Vistas
Live Search in PHP using AJAX working, but buttons not in td

my live search in working perfectly, but my tags are not in td. I can't figure out what is the problem. The picture, and the code are below. Thank you in advance. The problem is down there in td, the the tags. how it looks like

enter code here    
<?php

@include('./config/constants.php');
$output = '';

if (isset($_POST['query'])) {
    $search = $_POST['query'];
    $stmt = $conn->prepare("SELECT * FROM clients WHERE full_name LIKE CONCAT('%',?,'%') OR email LIKE  CONCAT('%',?,'%')");
    $stmt->bind_param("ss", $search, $search);
} else {
    $stmt = $conn->prepare("SELECT * FROM clients");
}
$stmt->execute();
$result = $stmt->get_result();

if ($result->num_rows > 0) {
    $output = "<tr>
                <th>ID</th>
                <th>Full Name</th>
                <th>E-mail</th>
                <th>Phone</th>
                <th>City</th>
                <th>Address</th>
                <th>Actions</th>
            </tr>
            ";
    while ($row = $result->fetch_assoc()) {
        $output .= "<tr>
                        <td>" . $row['id'] . "</td>
                        <td>" . $row['full_name'] . "</td>
                        <td>" . $row['email'] . "</td>
                        <td>" . $row['phone'] . "</td>
                        <td>" . $row['city'] . "</td>
                        <td>" . $row['address'] . "</td>
                        <td>"
?>
        <a href="<?php echo SITEURL; ?>/update-client.php?id=<?php echo $row['id']; ?>" class="main-btn">Update Client</a>
        <a href="<?php echo SITEURL; ?>/delete-client.php?id=<?php echo $row['id']; ?>" class="danger-btn">Delete Client</a>
<?php
        "</td>
                    </tr>";
    }
    echo $output;
} else {
    echo "<h3>No Records found!</h3>";
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You're outputting the links before the table rows.
You output them directly and then later output the rows in the variable $output.
Remove the ?> and <?php tags in your while loop and have the buttons be part of the $output string

while ($row = $result->fetch_assoc()) {
    $output .= "<tr>
                    <td>" . $row['id'] . "</td>
                    <td>" . $row['full_name'] . "</td>
                    <td>" . $row['email'] . "</td>
                    <td>" . $row['phone'] . "</td>
                    <td>" . $row['city'] . "</td>
                    <td>" . $row['address'] . "</td>
                    <td>" . '<a href="'.SITEURL.'/update-client.php?id='.$row['id'].'" class="main-btn">Update Client</a>'.
                            '<a href="'.SITEURL.'/delete-client.php?id='.$row['id'];.'" class="danger-btn">Delete Client</a>'.
                  ."</td>
                </tr>";
}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda