Problem in the returnvalue of a function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I have a problem in the response of a php-function.
Here the query on the mysql-prompt.


mysql> select * from product_price where product_id=7 and from_price <=5;
+------------------+------------+---------------+------------+----------+-------
-----------+---------------------+---------------------+-----------+-----------+
------------------+
| product_price_id | product_id | product_price | from_price | to_price |
product_currency | product_price_vdate | product_price_edate | cdate     |
mdate     | shopper_group_id |
+------------------+------------+---------------+------------+----------+-------
-----------+---------------------+---------------------+-----------+-----------+
------------------+
|                7 |          7 |        149.99 |          0 |     NULL | USD  
           |                   0 |                   0 | 950321754 | 966506270
|                5 |
|               16 |          7 |          2.99 |          1 |        2 | USD  
           |                   0 |                   0 | 966589140 | 966589140
|                6 |
|               17 |          7 |          1.99 |          3 |        5 | USD  
           |                   0 |                   0 | 966589140 | 966589140
|                6 |
+------------------+------------+---------------+------------+----------+-------
-----------+---------------------+---------------------+-----------+-----------+
------------------+
3 rows in set (0.00 sec)

And here is the function I have written in php

  /*************************************************************************
  ** name: select_price()
  ** created by:
  ** description:
  ** parameters:
  ** returns:
  **************************************************************************/
  function select_price($product_id,$quantity) {

    echo "Product-ID  ";
    echo $product_id;
    echo "   Quantity   ";
    echo $quantity;
    echo "   ";
    $db = new ps_DB;

    $q  = "SELECT * FROM product_price ";
    $q .= "WHERE product_id= " . $product_id . " AND from_price <= " .
$quantity ." ";
    $q .= "AND to_price >= " . $quantity . " ";

    $db->query($q);
    echo "\n";
    echo $q;
    echo "\n";
    return True;
   }

This is the line for calling the function (in the code one line):
     
$price=$ps_product_price->select_price($cart[$i]["product_id"],$cart[$i]["quanti
ty"]);
       //printf("%.2f", $price["product_price"]);

      printf("%.2f",$price);



I don't understand why the function ever returns the price 1.00 by different
quantities.

Regards,
Ruprecht

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux