It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming PHP and MySQL Forum

Updating a Basket

Moderator: Malcolm

Updating a Basket

Postby skybird on Tue May 24, 2005 7:55 am

//I would like to add a facility to remove an item from a basket
//I have a basket table in which details are stored
//The following is the code to select the data from the basket
//table for the relevant basket id


$sql="select * from basket where basketrefno='$nextbasketid';";
$data=mysql_query($sql,$dbh) or die("error 3");

//I have added a form to include a check box for each record displayed
echo "<form name='updatebasket' method='post'
action='basket.php?yourbasketid=$nextbasketid'>";

//headings for the table
echo "<table border=3 bordercolor=green><tr><td><center>Picture</td>";
echo
"<td>BID</td><td><center>Product</td><td><center>Title</td><td><center>Price
</td>";
echo "<td>Qty</td><td>Total Cost</td><td>Remove</td></tr>";


//code to display all data from the basket table

while ($item = mysql_fetch_assoc($data))
{
echo"<tr><td><img src='images/" . $item["picturename"] . "'></td>";
echo "<td>" . $item["basketrefno"] . "</td><td><b>" . $item["partnumber"]
. "</b></td>";
echo "<td>" . $item["title"] . "</td>";
echo "<td><font color=red><b>" . "£" . $item["price"] .
"</b></font></td>";
echo "<td>" . "<input name='quantity' type='text' size='2' value=" .
$item["quantity"] . "></td>";
echo "<td>" . $item["price"]*$item["quantity"] . "</td>";
echo "<td><input type='checkbox' name='remove' value='1'>" . "</td>";
}
echo "</table>";


echo "<input type='submit' name='Submit' value='Update Basket'>";
echo "</form>";

//I would like the functinoality when the contents of the basket table are
displayed to be able to remove an item from the basket
//A check box would be included in each row, if the check box is ticked
//The update basekt button would refresh the basket.php page and remove the record from the basket table
//How do you code, if a checkbox is ticked for an item, the update button would refresh the page and remove the item from the table
//i.e. If checkbox =1 then delete record
//I am not sure how to code within the while statement
Many Thanks
skybird
 
Posts: 0
Joined: Tue May 24, 2005 7:47 am
Location: England

Who is online

Users browsing this forum: No registered users and 0 guests