Hi
I'm having a bit of a trouble getting some data from my database and displaying the list on the web page using the following code:
<?
//connect to database
$host="localhost";
$connect = mysql_connect($host,"","")
or die ("Couldn't connect to server.");
$db = mysql_select_db("liveweb", $connect)
or die ("Couldn't connect to database.");
//sql query to get forthcoming show list from database
$query = "SELECT DateTime, ShowTitle, Available FROM shows WHERE DateTime >= now()";
$result = mysql_query ($query)
or die ("Couldn't execute query".mysql_error());
//while loop to return results into multi-dimensional array
$i=1;
while ($row = mysql_fetch_array($result,MYSQL_ASSOC))
{
foreach ($row as $colname => $value)
{
$row[$i][$colname] = $value;
}
$i++;
}
return $array;
//diplay results
echo "<table cellspacing='15'>";
echo "<tr><td colspan='4'><hr></td></tr>";
for ($j=1;$j<=sizeof($array);$j++)
{
echo "<tr>\n
<td>$j</td>\n
<td>{$row['DateTime']}</td>\n
<td>{$row['ShowTitle']}</td>\n
<td>{$row['Available']}</td>\n
<\tr>\n";
echo "<tr><td colspan='4'><hr></td></tr>\n";
}
echo "</table>\n";
?>
At first I thought this was going to be fairly straight forward but when I come to load the web page it's completely blank. I'm sure its something fairly obvious but I just can't see anything myself. Any suggestions anyone?
Thanks in advance.