Hi all, hope someone can help,
I have a form that inputs to the database then reads the data in php,my problem is the table displayed in the browser shows all the current data but not the new inputted data,
now if i go into the php script in notepad and press save when i go to the browser and refresh the new data appears
see code below
thanks for any help
Code:
<HTML>
<HEAD>
<LINK REL=stylesheet TYPE="text/css" HREF="wmd.css">
<META HTTP-EQUIV="Refresh" CONTENT="10;URL=<?php echo $_SERVER['PHP_SELF']; ?>">
<HTML>
<HEAD>
<LINK REL=stylesheet TYPE="text/css" HREF="wmd.css">
<TITLE>Inserting Data into a Database</TITLE>
</HEAD>
<BODY><center>
<?php
// Set the variables for the database access:
$host="localhost";
$user="Paul";
$password="";
$database = "auction";
$TableName = "auctiondata";
$connection = mysql_connect($host,$user,$password)
or die ("couldn't connect to server");
$db = mysql_select_db($database,$connection)
or die ("Couldn't select database");
$Query = "SELECT * FROM $TableName";
//print ("The query is:<BR>$Query<P>\n");
if (mysql_db_query ($database, $Query, $connection))
{
print ("Current items Available!<BR>\n");
}
else
{
print ("sorry !!auction Id already in use<BR>\n");
}
$query = "SELECT * FROM auctionData";
$result = mysql_query($query)
or die ("Couldn't execute query.");
/ Display results in a table /
print ("<TABLE BORDER=1 WIDTH=\"95%\" CELLSPACING=2 CELLPADDING=2 ALIGN=CENTER>\n");
print ("<TR ALIGN=CENTER VALIGN=TOP>\n");
print ("<th ALIGN=CENTER VALIGN=TOP>AuctionId</th>\n");
print ("<th ALIGN=CENTER VALIGN=TOP>Name</th>\n");
print ("<th ALIGN=CENTER VALIGN=TOP>Item</th>\n");
print ("<th ALIGN=CENTER VALIGN=TOP> Item Description</th>\n");
print ("<th ALIGN=CENTER VALIGN=TOP>Startprice</th>\n");
print ("<th ALIGN=CENTER VALIGN=TOP>Startdate</th>\n");
print ("<th ALIGN=CENTER VALIGN=TOP>Expiresdate</th>\n");
print ("</TR>\n");
while ($row = mysql_fetch_array($result))
{
$auctionId = $row['auctionId'];
$userId = $row['userId'];
$item = $row['item'];
$itemDesc = $row['itemDesc'];
$startPrice = $row['startPrice'];
$startDate = $row['startDate'];
$expiresDate = $row['expiresDate'];
print ("<TR ALIGN=CENTER VALIGN=TOP>\n");
print ("<TD ALIGN=CENTER VALIGN=TOP>$auctionId</TD>\n");
print ("<TD ALIGN=CENTER VALIGN=TOP>$userId</TD>\n");
print ("<TD ALIGN=CENTER VALIGN=TOP>$item</TD>\n");
print ("<TD ALIGN=CENTER VALIGN=TOP>$itemDesc</TD>\n");
print ("<TD ALIGN=CENTER VALIGN=TOP>$startPrice</TD>\n");
print ("<TD ALIGN=CENTER VALIGN=TOP>$startDate</TD>\n");
print ("<TD ALIGN=CENTER VALIGN=TOP>$expiresDate</TD>\n");
print ("</TR>\n");
}
mysql_close ($connection);
echo "</table>\n";
?>
</center>
</body>
</html>