I am attempting to create a shopping basket/checkout function but I am having a few issues.
The basket is for a photography project, where photographs are read in from the database and displayed on the page. I then want a user to be able to select any number of photographs and for those to be added to a basket
The current method relies on a drop down box for each photograph for a user to select none(default) small or large. then once a user has selected the images they want they click a submit button which populates the basket and displays the items and a total and takes them to the album cover page and they can go through the same process selecting the album they want. I know the method is rather crude but as I have previously mentioned my programming skills aren't up to scratch but I am improving. Is there a simpler way to achieve what I want to?
I am having trouble populating the basket initially, I know I need to create a loop in order to edit my gallery table field 'status' where status is either 1,2 or 3 - 1 being not included, 2 being small 3 being large. defualt is 0 as it has not yet been processed. This data is being drawn from each of the drop down boxes...
<div id="rightbar">
<h4>Shopping Basket</h4>
<?php require ("basket.php");?>
</div>
<div id="content">
<table width="530" height="272" border="0">
<?php
$sql = "SELECT * FROM gal";
$result = $conn->query($sql) or die(mysqli_error());
if($result){
while($row = $result->fetch_object()){
?>
<tr>
</td>
<td height="69"><img src="<?php echo $folderpath . $row->foldername . "/" . $row->imgname; ?>" width="530" height="272"/></td>
<tr>
<td><select name="status">
<option value="1">do not include</option>
<option value="2">add 8x6 image</option>
<option value="3">add 10x8 image</option>
</select></td>
</tr>
</tr>
</tr>
<?php
}
}
?>
<form>
<small> Add selected images to basket</small>
<input type="button" value="Add" onclick="update_status"()/>
</form>
<?php
function update_status(){
$update_status = "SET statusid = $status WHERE gal.imgname = $row->imgname AND gal.foldername = $row->foldername";
}
?>
<td>
The next problem I am having is the basket itself, I have inserted some dummy data and I am trying to emmulate a populated basket and I am getting an error around line 24:
Parse error: parse error in C:\wamp\www\website\basket.php on line 24
The current code:
<table id="shopping_cart_items">
<tr>
<th>Photographs</th>
<th>Price</th>
<!----Populate the basket----------------->
<?php $basket_sql = "SELECT cust.username, gal.imgname, status.status, status.price FROM cust, status, gal WHERE cust.custid = gal.custid AND gal.statusid = status.statusid AND status.status != 'Not Included' AND cust.username = 'test'";
$basket_result = $conn->query($basket_sql) or die(mysqli_error());
if($basket_result){
while($row = $basket_result->fetch_object()){
?>
</tr>
<td> <?php echo $row->imgname; ?><br/ ></td>
<td>£<?php echo $row->price;?>.00 <br/ ></td>
<?php
}
}
?>
<!----Calculate the total----------------->
[B]HERE->[/B] <?php sql_cover ="SELECT cust.username, albumcover.covername, albumcover.coverprice FROM cust, albumname WHERE cust.coverid = albumcover.coverid AND cust.username = $username";
$cover_result = $conn->query($sql_cover) or die(mysqli_error());
if($cover_result){
while($row = $cover_result->fetch_object()){
?>
<tr/>
<td><?php echo $row->covername; ?><br/ ></td>
<td><?php echo $coverprice; ?><br/ ></td>
<?php
}
}
?>
</table>
I hope this explains the issue well enough, if anyony has any suggestions or advice about what I should do, or whether there is an easier way to achieve my overall goal I would really appreciate the input.
Many thanks
m