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

236
Vistas
Search through Postgresql using search bar, then display it

The Problem

Hello, I am creating a search function that will allow users to search for a specific E-Number and see whether it is derived from animals or not, basically seeing if it's vegan. I have successflly connected to the database using PHP on my website but the pg_query.

What I Want to Happen:

I want a user to being able to search for an E-number in a seach bar like the example below:

enter image description here

There is four columns in the table, I want to allow the user to search through one, this being 'code', and then displaying an answer, this being the 'vegan' column in my database.

The Code so far

<?php       
    // Connecting, selecting database
    $dbconn = pg_connect("***** port=*****
        dbname=***** user=***** password=*****")
        or die('Could not connect: ' . pg_last_error());    

    // Performing SQL query
    $query = 'SELECT * FROM enumbers';
    $result = pg_query($query) or die('Query failed: ' . pg_last_error());

    // Printing results in HTML
    echo "<table>\n";
    while ($line = pg_fetch_array($result, null, PGSQL_ASSOC)) {
        echo "\t<tr>\n";
        foreach ($line as $col_value) {
            echo "\t\t<td>$col_value</td>\n";
        }
        echo "\t</tr>\n";
    }
    echo "</table>\n";
?>
over 4 years ago · Santiago Trujillo
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