Code:
<?php
if (!isset($query) || empty($query))
{$query = "select * from sccp";}
//stripslashes are needed because the select statement is
//coming from a form.
$query=stripslashes($query);
mysql_connect("localhost", "dba", "purge26")
or die("Could not connect to MySql Server");
mysql_select_db("shift")
or die("Could not open the Shift Database");
$result = mysql_query($query) or
die( mysql_error() );
$number_cols = mysql_num_fields ($result);
echo "<b>query: $query</b>";
//layout table header
echo "<table border = 1>\n";
echo "<tr align=center>\n";
for ($i=0; $i<$number_cols; $i++)
{
echo "<th>" . mysql_field_name($result, $i). "</th>\n";
}
echo "</tr>\n"; //end table header
//layout table body
while ($row = mysql_fetch_row($result))
{
echo "<tr align=left>\n";
for ($i=0; $i<$number_cols; $i++)
{
echo "<td>";
if (!isset($row[$i])) //test for null value
{echo "NULL";}
else
{echo $row[$i];}
echo "</td>\n";
}
echo "</tr>\n";
}
echo "</table>";
?>
And I want to able to perform INSERTS and UPDATES from within the html tables, but I cant figure it out the best way to do it....I need more caffeine, but until then, I need assistance/opinions.
Bookmarks