I,m trying to put the data into a table ,but can,t suss it, very new to php
can anyone help
thanks in advance
Ducca
Code: Select all
<HTML>
<HEAD>
<LINK REL=stylesheet TYPE="text/css" HREF="wmd.css">
<HTML>
<HEAD>
<LINK REL=stylesheet TYPE="text/css" HREF="wmd.css">
<TITLE>Inserting Data into a Database</TITLE>
</HEAD>
<BODY><center>
<?php
/* This page receives and handles the data generated by "savedata.html". */
// incoming data.
$auctionId = $_POSTї"auctionId"];
$title = $_POSTї"title"];
$userId = $_POSTї"userId"];
$itemDesc = $_POSTї"itemDesc"];
$image = $_POSTї"image"];
$startPrice = $_POSTї"startPrice"];
$startDate = $_POSTї"startDate"];
$expiresDate = $_POSTї"expiresDate"];
// 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 = "INSERT into $TableName (auctionId,title,userId,itemDesc,image,startPrice,startDate,expiresDate)
values ('$auctionId','$title','$userId','$itemDesc',
'$image','$startPrice','$startDate','$expiresDate')";
//print ("The query is:<BR>$Query<P>\n");
if (mysql_db_query ($database, $Query, $connection))
{
print ("Your Item was succsessfully added to auction!<BR>\n");
}
else
{
print ("sorry !! try again Remember auction Id<BR>\n");
}
/*mysql_close ($connection);*/
$query = "SELECT * FROM auctionData";
$result = mysql_query($query)
or die ("Couldn't execute query.");
/* Display results in a table */
echo "<center><h1>auctions</h1></center>";
echo "<table cellspacing='25'>";
echo "<tr><td colspan='8'><hr></td></tr>";
while ($row = mysql_fetch_array($result))
{
extract($row);
$datastring = $auctionId."\n".$title."\n".$userId."\n".$itemDesc."\n".$image."\n".$startPrice.
"\n".$startDate."\n".$expiresDate."\n";
echo "<tr>\n
<td>$datastring </td>\n
</tr>\n";
// echo "<tr><td colspan='3'><hr></td></tr>\n";
}
echo "</table>\n";
?></center>
</BODY>
</HTML>