The Problem
I am creating a search that allows users to see if an enumber is vegan, but no matter what enumber I search, it is simply printing the word vegan when I search for a enumber. i want it to print out what is in the 'vegan' column in the database.
Code
<?php
// Connecting, selecting database
$dbconn = pg_connect("host=***** port=*****
dbname=***** user=***** password=*****")
or die('Could not connect: ' . pg_last_error());
//collect
if(isset($_POST['search'])) {
$searchq = $_POST['search'];
// $searchq = preg_replace("#[^0-9a-z]#i"."".$searchq);
// Performing SQL query
$query = "SELECT vegan FROM enumbers WHERE code LIKE '%$searchq%'";
$ret = pg_query($dbconn, $query);
if(!$ret){
echo pg_last_error($dbconn);
exit;
}
$output = '';
while($row = pg_fetch_assoc($ret)){
$code = $row['code'];
$name = $row['name'];
$type = $row['type'];
$vegan = $row['vegan'];
$output .= '<div> '.vegan.' ';
}
}
pg_close($dbconn);
?>