I am a newbie with PHP/PostgreSQL, but what I am trying to do is populate a listbox on a form with the results from a query against the database. My code is below, any help is much appreciated. My results show up as:
'Array' 'No data available'.
The 'No data available' is from my Else condition if nothing is found, but I know it should return one value.
//Code
$query = "SELECT DISTINCT type FROM tblmain";
$result = pg_query($connection, $query) or die("Error in query: $query." . pg_last_error($connection));
$rows = pg_num_rows($result);
if ($rows > 0)
for ($i=0; $i<$rows; $i++)
{
list($results[]) = pg_fetch_row($result);
{
echo $results;
}
}
else
?>
<font size="-1">No data available.</font>
<?
{
pg_close($connection);
}
'Array' 'No data available'.
The 'No data available' is from my Else condition if nothing is found, but I know it should return one value.
//Code
$query = "SELECT DISTINCT type FROM tblmain";
$result = pg_query($connection, $query) or die("Error in query: $query." . pg_last_error($connection));
$rows = pg_num_rows($result);
if ($rows > 0)
for ($i=0; $i<$rows; $i++)
{
list($results[]) = pg_fetch_row($result);
{
echo $results;
}
}
else
?>
<font size="-1">No data available.</font>
<?
{
pg_close($connection);
}