one file php html page
Posted: Thu Dec 17, 2009 9:06 am
I want to display an html page with a table and a submit button which will insert anathor row to the same table and will come to the same page with updated record, How I coded it is :
Now I have stucked at the button action in the code as commented, what to do there and where exactly I need to write the function any help apprecieated.
Code: Select all
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php define( "DATABASE_SERVER", "localhost" );
define( "DATABASE_USERNAME", "root" );
define( "DATABASE_PASSWORD", "password" );
define( "DATABASE_NAME", "comments" );
//connect to the database
$mysql = mysql_connect(DATABASE_SERVER, DATABASE_USERNAME) or die(mysql_error());
//select the database
mysql_select_db( DATABASE_NAME );
//asign the data passed from Flex to variables
//Query the database to see if the given username/password combination is valid.
$query = "SELECT * FROM comments_table";
$result = mysql_query($query);
if (!$result) {
die("Query to show fields from table failed");
}
echo "<table border='1'>";
echo "<tr>";
echo "</td>";
echo "<h1>Showing 30 Entries:</h1>";
echo "<table border='1'>";
while($row = mysql_fetch_row($result))
{
echo "<tr>";
// $row is array... foreach( .. ) puts every element
// of $row to $cell variable
echo "<td>$row[1]</td>";
echo "<td>$row[2]</td>";
echo "</tr> <br/>";
}
mysql_free_result($result);
echo "</td>";
echo "</tr> <br/>";
?>
<tr>
<td>
<form name="form1" method="post" action="">
<textarea name="textarea" cols="100" width="100%"></textarea>
<input type="submit" name="Submit" value="Submit">
</form>
</td>
</tr>
</body>
</html>