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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.