Jump to content

PierreL

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

PierreL's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Ok i think i;ve cracked it if(($vbc_finalprice >= 0.01) and ($vbc_finalprice <= 500.00)) { $vbcomm_sum = 15.00; }else if (($vbc_finalprice >= 500.01) and ($vbc_finalprice <= 10000.00)){ $vbcomm_sum = $vbc_finalprice * 0.05 + 15.00; }else if($vbc_finalprice >= 10000.01){ $vbcomm_sum = $vbc_finalprice * 0.03 + 15.00; }else{ $vbcomm_sum = 0; } $vbc_commission = $vbcomm_sum; return $vbc_commission;
  2. Hi Blade No i dont expect you guys to do it, just needed advise, this is what i tried. $vbc_finalprice = 200.00; if($vbc_finalprice <= 500.00) { $vbcomm_sum = 15.00; }else if ($vbc_finalprice >= 500.01 && $vbc_finalprice <= 10000.00){ $vbcomm_sum = $vbc_finalprice * (1 - 0.05) + 15.00; }else($vbc_finalprice >= 10000.01){ $vbcomm_sum = $vbc_finalprice * (1 - 0.03) + 15.00; } $vbc_commission = $vbcomm_sum; return $vbc_commission; print "$vbc_commission"; PHP does not seem to like this, but you get what i am trying to do here else if ($vbc_finalprice >= 500.01 && $vbc_finalprice <= 10000.00) Cheers
  3. Hi Guys I'm pretty new to PHP and need desperate help to modify a function. This function calculates commision for an auction. function vbccalc_commission($vbc_finalprice, $vbcomm_increments){ settype($vbc_finalprice, "float"); // Build the Commissions Structure $vbcomm_inc = explode("\n", $vbcomm_increments); $vbccomm_index = '0'; foreach($vbcomm_inc AS $vbcomm_inc_bit){ $vbccomm_bit = explode("|", $vbcomm_inc_bit); $vbccomm_index++; $vbccomm_level[$vbccomm_index] = $vbccomm_index; settype($vbccomm_bit[0], "float"); $vbccomm_price[$vbccomm_index] = $vbccomm_bit[0]; settype($vbccomm_bit[1], "float"); $vbccomm_fee[$vbccomm_index] = $vbccomm_bit[1]; $max = $vbccomm_index; } $count = $max; $vbcomm_sum = '0'; while ($count > 0) { if($vbc_finalprice >= $vbccomm_price[$count]){ $vbcomm_step = $vbc_finalprice - $vbccomm_price[$count]; $vbcomm_bit = $vbcomm_step * $vbccomm_fee[$count]; $vbcomm_sum = $vbcomm_sum + $vbcomm_bit; $vbc_finalprice = $vbc_finalprice - $vbcomm_step; } $count--; } $vbc_commission = $vbcomm_sum; return $vbc_commission; } The $vbcomm_increments is not needed anymore. The new commision structure can be hard coded. $vbcomm_increments allowed you to modify the script but the modifier can not do what i want the script to do. Below is an example of what i want this script to do - Listing fee for all items is R 15.00 - Goods listed from R 0.01 - R 500.00, only the listing fee has to be paid. - From R 500.01 - R 10 000.00, listing fee + 5% - From R 10 000.01 and above, listing fee + 3% Examples - You sell a fly box with flies for R 200.00, the fee is the listing fee of R 15.00 - You sell a rod for R 600.00, the fee is the listing fee (R 15.00) + 5% of R 600.00 (R 30.00) = R 45.00 - You sell a Sage for R 1200.00, the fee is the listing fee (R 15.00) + 5% of R 1200.00 (R60.00) = R 75.00 - You sell your vehicle for R 50 000.00, the fee is the listing fee (R15.00) + 3% of R 50 000.00 (R 1500.00) = R 1515.00 The guy that wrote this mod for an auction scripts is not supporting this anymore and is un available which leaves me in a bad spot not being able to launch. I would be really gratefull if someone can help me out. Thanks in advance All the best Pierre
  4. You see it wont work to make $offset an empty string, it needs a value from the query. The code is part of a script to put in page numbers  on a result set. Is there now a way to tell php that the variable is only declared further down the page and to fetch its value from there.
  5. Good Day I have a problem with the code below in that i am using a Variable that can only get declared lower down in the code, so offcorse i get the  " Undefined variable: offset " is there a work around i just cant declare it higher up. [code]<?php   class Pager   {       function getPagerData($numHits, $limit, $page)       {           $numHits  = (int) $numHits;           $limit    = max((int) $limit, 1);           $page    = (int) $page;           $numPages = ceil($numHits / $limit);           $page = max($page, 1);           $page = min($page, $numPages);           $offset = ($page - 1) * $limit;           $ret = new stdClass;           $ret->offset  = $offset;           $ret->limit    = $limit;           $ret->numPages = $numPages;           $ret->page    = $page;           return $ret;       }   } $isFirst = true; $result = ""; $selectbase = "select id , type , species , userid , name , description , largepic , country , province from pics";   if ( $type==""){ }else{ if ($isFirst){ $result = $result . " WHERE "; $isFirst = false; }else{ $result = $result . " AND "; } $result  = "" . $result . " TYPE = '$type' "; } /* ======================================================================================================= */ if ( $country==""){ }else{ if ($isFirst){ $result = $result . " WHERE "; $isFirst = false; }else{ $result = $result . " AND "; } $result = "" . $result . " COUNTRY  = '$country' "; } /* ======================================================================================================= */ if ( $specie==""){ }else{ if ($isFirst){ $result = $result . " WHERE "; $isFirst = false; }else{ $result = $result . " AND "; } $result = "" .  $result . " SPECIES  = '$specie' "; } /* ======================================================================================================= */ if ( $province==""){ }else{ if ($isFirst){ $result = $result . " WHERE "; $isFirst = false; }else{ $result = $result . " AND "; } $result =  "" . $result . " PROVINCE  = '$province' "; } $page      = getRequestVariable("page"); $limit      = 5; $tail        = " order by id desc limit $offset, $limit ";                 $fullquery = $selectbase . $result . $tail;                                 $fresult    = mysql_query( "$fullquery"); $total      = mysql_result($fresult, 0, 0); $pager    = Pager::getPagerData($total, $limit, $page); $offset    = $pager->offset; $limit      = $pager->limit; $page      = $pager->page; for ($i=0; $i < (mysql_num_rows($fresult)); $i++) { $thisrow = mysql_fetch_row($fresult); ?> [/code]
×
×
  • 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.