Jump to content

Barand

Moderators
  • Posts

    22,736
  • Joined

  • Last visited

  • Days Won

    647

Everything posted by Barand

  1. I thought you would have realised in your initial code that you had the total_receivables from your array_sum() function call. If in doubt what a function is doing, there is always the manual Getting total expenses would be very similar. Subtracting one from the other is an easy bit.
  2. $diff = $total_receivables - $total_expenses;
  3. I'd recommend using a DECIMAL type for currency rather than FLOAT e.g. price DECIMAL(10,2) so you have a fixed number of decimal places.
  4. Consider it a good staring point for the final model. Models tend to evolve as development of the project progresses.
  5. The relationship between order and and product is via orderItem
  6. +--------------+ +--------------+ +----------------+ | product | | product_type | | order | +--------------+ +--------------+ +----------------+ +---| product_id | +---| pType | | orderID |--+ | | pName | | | typedescrip | | memberID | | +------------------+ | | pType |>--+ +--------------+ | orderDate | | | order_item | | | pDescription | +----------------+ | +------------------+ | +--------------+ | | order_item_id | | +---<| orderID | | | productID |>---+ | qty | +------------------+
  7. Product_type -1----------< Product ie One to Many +--------------+ +--------------+ | product | | product_type | +--------------+ +--------------+ | product_id | +--------| pType | | pName | | | typedescrip | | pType |>------+ +--------------+ | pDescription | +--------------+ While I'm here, your members table needs a memberID as its primary key otherwise you have nothing to join on. Your model allows only single product per order - it that what you want?
  8. No "old farts" that I am aware of.
  9. You'll find that serializing data it not used very much these days, largely abandoned in favour of JSON data $data = [ 'count' => 1, 'total' => 5, 'average' => 5 ]; echo "Serialized: " . serialize($data); echo "JSON: " . json_encode($data);; gives Serialized: a:3:{s:5:"count";i:1;s:5:"total";i:5;s:7:"average";i:5;} JSON: {"count":1,"total":5,"average":5}
  10. So just, for example, "SELECT id,name, email FROM ..." so you only retrieve what you need. That's why you shouldn't use "SELECT * " in queries as that retrieves every column, need it or not, and slow your queries. [EDIT] PS That's one of the reasons not to use SELECT *.
  11. It seems reasonable to me, given the initial caveat.
  12. You say all but only select a single item. And you don't have a submit button! Where is the $iditemm value coming from? No idea - where is it supposed to come from?
  13. while (($p1 = strpos($str, 'S', $p2)) !== false) { // while there is a next 'S', get its position $p2 = strpos($str, 's', $p1); // find position of following 's' if ($p2===false) { // if there is no following 's' $p2 = strlen($str); // assume its position is the end of the string } echo substr($str, $p1, $p2-$p1+1) . '<br>'; // echo the characters between the S and s }
  14. Store the test dates - that will tell you who got there first.
  15. You'll affect performance more, and complicate the queries, by splitting your users across more than one table. It would also break a rule of DB design - don't store derived data
  16. +-----------+ | user | +-----------+ | user_id |--------+ | name | | | email | | +-----------------+ | phone | | | answer | +-----------+ | +-----------------+ | | answer_id | +----0<| user_id | | question_no | | selected_choice | +-----------------+ One user table. Query to find which answered 4 questions SELECT u.user_id , u.name FROM user u JOIN answer a USING (user_id) GROUP BY u.user_id HAVING COUNT(answer_id) = 4
  17. Is there any chance that you might answer that question sometime soon? (At my age an fear I am running out of the time needed to get you thinking about what your code is doing)
  18. There is an absence of DB query code in anything you have posted and you have not explicitly stated the origin of all those values that you are passing in the query string ($_GET data), so here is my guess... Does $_GET['did_ivr_disable'] contain the value from the database that you need? Or have you not thought about it?
  19. If you always set it to zero, what other result do expect? I did say that it should be the value from your DB.
  20. I'm equally sorry that we are new to telepathic communication and so have no idea what your code is that is giving the result below. Did you implement the method I showed you?
×
×
  • 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.