i am fairly new to php and mysql and was incidentally bugfixing a project a friend of mine had done. let me get straight to it.
this is a php file that cretaes a temp db:
<?php
include("config.php");
//define the temp table
$query = "CREATE TABLE carttemp(
carttemp_hidden INT(10) NOT NULL AUTO_INCREMENT,
carttemp_sess CHAR(50) NOT NULL,
carttemp_prodnum CHAR(5) NOT NULL,
carttemp_quan INT(3) NOT NULL,
PRIMARY KEY (carttemp_hidden),
KEY(carttemp_sess))";
$temp = mysql_query($query) or die(mysql_error());
echo "Temporary cart table created successfully!";
?>
this is a fragment of the html file that is trying to access this table:
<table border="1" align="left" cellpadding="5">
<tr>
<td>Quantity</td>
<td>Item Name</td>
<td>Price Each</td>
<td>Extended Price</td>
<td></td>
<td></td>
</tr>
<?php
$_sessid = session_id();
$query = "SELECT * FROM carttemp WHERE carttemp_sess = '$sessid'";
$results = mysql_query($query) or die (mysql_error());
$total = 0;
while($row = mysql_fetch_array($results))
{
extract($row);
$prod = "SELECT * FROM product WHERE product_prodnum = '$carttemp_prodnum'";
$prod2 = mysql_query($prod);
$prod3 = mysql_fetch_array($prod2);
extract($prod3);
echo "<tr><td>";
echo $carttemp_quan;
echo "</td>";
echo "<td>";
echo "<a href=\"getprod.php?prodid=" . $product_prodnum . "\">";
echo $product_name;
echo "</td></a>";
echo "<td align=\"right\">";
echo $product_price;
echo "</td>";
echo "<td align=\"right\">";
//get extended price
$extprice = number_format($product_price * $carttemp_quan,2);
echo $extprice;
echo "</td>";
echo "<td>";
echo "<a href=\"cart.php\">Make changes to Cart.</a>";
echo "</td>";
echo "</tr>";
//add extended price to total
$total = $extprice + $total;
}
?>
<tr>
<td colspan="4" align="right">Your total before shipping is :</td>
<td align="right"> <?php echo number_format($total, 2); ?></td>
<td></td>
<td></td>
</tr>
</table>
the thing is i am unable to display the table details in the above code. can anyone please help?