Jump to content

Associating Price with items in array


Schlo_50

Recommended Posts

Hello,

 

I have an ordering script which i have been working on for a while now. It's in the finishing stages, and lastly i'd like to be able to get the prices of any items selected and total them.

 

What i need help with is associating a selected item with a price. Selected items are put into an array like so:

 

foreach($_POST['orderid'] as $id){
    $orderid[] = $id;

$orderid = implode(',', $orderid);

 

All information is pulled from my database and is done so using the code below:

 

while($row = odbc_fetch_array($sql2))
{
$category = $row["CategoryName"];
$productid = $row["ProductId"];
$productname = $row["ProductName"];
$price = $row["Price"];
$type = $row["Type"];
$habit = $row["Habit"];
$colour = $row["Colour"];
$status = $row["Status"];


// find out if category has changed
// if so, print it, and it's contents
if ($category != $prevcat)  {
	echo "<p class='title'><u>{$category}</u></p>"; 
}

echo  "<p class=main2>
<strong>{$productname}</strong> - 
({$colour} {$status} Item#{$productid}) 
<span class=address1>£{$price} <input name=\"orderid[]\" value=\"{$productid}\" type=\"checkbox\"/> 
<input name=\"quantity[{$productid}]\" type=\"text\" size=\"3\" maxlength=\"3\" /></span></p>";	

 

I don't know how to grab the single price associated with an item when it is selected using a checkbox.

 

Any help/ideas?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/89379-associating-price-with-items-in-array/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.