Jump to content

Recommended Posts

I have a variable $listing_fee. When $items_found = mysql_num_rows($result) give a result of more than one item, it creates a new row. Each row generates a $listing_fee for each item like it should. Each $listing_fee may be different. The problem here, is that the $listing_fee has the same name on each row, but i want to add(calculate the amounts. I cannot rename $listing_fee to $listing_fee1, $listing_fee2 and so on since the amount of rows may differ each time. does anyone know how i can make add $listing_fee + whatever other $listing_fee that may result?

Thanks in advance.

Hope you can understand what im trying to do. Oh!, almost forgot the amount that defines the $listing_fee does not come from mysql, it is passed from another page through include.
I have a query that selects users info and items purchased from mysql database and
creates a different row for each result. I added a variable $listing_fee to
the result row. So now each row "mysql_num_rows($result)" prints out something like this:

item number -- description -- fee
_____________________________________
123456 -- standard plan -- 1.00
1245 -- standard plan -- 1.00
321321 -- beyond plan -- 3.00
45646 -- second plan -- 2.50
458778 -- standard plan -- 1.00
----------------------------------------------------
The following variables represent the above each row.
$plan = description
$listing_fee = fee
----------------------------------------------------
Everything works fine and looks good. I get the number result
on each row like it should according to the plan and fee.
Below is some info that each row uses for each item. I am trying
to add(+) the rersults for each $listing_fee on each row to get a
$total_due. This is where the problem is. Each row variable is named
$listing_fee as it is created as many time of row result. So if the
customer purchased 20 plans, i will have 20 rows with different
price depending on the plan purchased. I need to add these together.

$standard_fee = 1.00;
$second_fee = 2.50;
$beyond_fee = 3.00;

if($plan == '1') {
$listing_fee = $standard_fee;
}

if($plan == '2') {
$listing_fee = $second_fee;
}

if($plan == '3') {
$listing_fee = $beyond_fee;
}

This is what i have done so far and gets me close to the total.


$total_due = mysql_num_rows($result)* $listing_fee;


This would work if all where priced the same.

"$listing _fee" is not mysql. Info is gathered from the same page or script.

Can someone help? The entire code is too long to post.
[img src=\"style_emoticons/[#EMO_DIR#]/wink.gif\" style=\"vertical-align:middle\" emoid=\":wink:\" border=\"0\" alt=\"wink.gif\" /] [b]jajtiii[/b]
You got it!

I knew it could be done, i was just not explaining myself good enough.

Thanks so much.
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.