Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in C:\website\webdev\robert.harrison\ITEC 3280\Coffee Shop\shoppingCart.php on line 32
Many thanks!!
<?php
session_start();
$conn = mysqli_connect(//deleted these parameters for obvious reasons);
$sku = $_SESSION['sku'];
$quantity = $_POST['quantity'];
$userid = $_SESSION['name'];
if($_SESSION['name'] == ''){
$_SESSION['signedIn'] = 'no';
header('Location: signIn.php');
}
else if($_POST['submit'] == 'Update Cart'){
$sql = "
SELECT sku, quantity
FROM cart
WHERE userid = ".$userid."';
";
$rs = mysqli_query($conn, $sql);
//$num_rows = mysqli_num_rows($rs);
while($row = mysqli_fetch_assoc($rs)){
$quantity = $_POST[$row['sku']];
$sql = "UPDATE CART
SET quantity = '".$quantity."'
WHERE userid = '".$userid."' AND sku = '".$row['sku']"';";
$rs = mysqli_query($conn, $sql);
$sql = "SELECT coffee_sku, coffee_name, coffee_price, quantity
FROM coffee
JOIN CART ON coffee_sku = sku
WHERE userid = '".$userid."';";
$rs = mysqli_query($conn, $sql);
echo "<form action'shoppinCart.php' method='post'>";
echo "<table name = 'cart'>
<tr>
<th>Coffee Name</th><th>Coffee Price</th><th>Quantity</th>
</tr>";
if (mysqli_num_rows($rs)== 0){
echo "No items are currently in your shopping cart.";
}
while($row = mysqli_fetch_assoc($rs)){
echo "<tr>";
echo "<td>". $row['coffee_name'] . "</td>";
echo "<td>$" . $row['coffee_price'] . "</td>";
echo "<td><input type='text' size='2' name='".$row['coffee_sku']."' value='" . $row['quantity'] . "'></td>";
echo "</tr>";
}
echo "<tr>
<td></td><td></td><td><input type='submit' name='update' value='Update Cart'</td>
</tr>";
echo "</table>";
echo "Displaying " . mysqli_num_rows($rs) . " items.";
mysqli_close($conn);
echo "</form>"
}
}
else{
$sql = "INSERT INTO CART
VALUES ('".$userid."', '".$sku."', '".$quantity."');";
$rs = mysqli_query($conn, $sql);
if(mysqli_affected_rows($conn) == 0){
echo "Insert failed!";
}
$sql = "SELECT coffee_sku, coffee_name, coffee_price, quantity
FROM coffee
JOIN CART ON coffee_sku = sku
WHERE userid = '".$userid."';";
$rs = mysqli_query($conn, $sql);
echo "<form action'shoppinCart.php' method='post'>";
echo "<table name = 'cart'>
<tr>
<th>Coffee Name</th><th>Coffee Price</th><th>Quantity</th>
</tr>";
if (mysqli_num_rows($rs)== 0){
echo "No items are currently in your shopping cart.";
}
while($row = mysqli_fetch_assoc($rs)){
echo "<tr>";
echo "<td>". $row['coffee_name'] . "</td>";
echo "<td>$" . $row['coffee_price'] . "</td>";
echo "<td><input type='text' size='2' name='".$row['coffee_sku']."' value='" . $row['quantity'] . "'></td>";
echo "</tr>";
}
echo "<tr>
<td></td><td></td><td><input type='submit' name='update' value='Update Cart'</td>
</tr>";
echo "</table>";
echo "Displaying " . mysqli_num_rows($rs) . " items.";
mysqli_close($conn);
echo "</form>"
}
?>


Sign In
Create Account


Back to top









