Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/30/2021 in all areas

  1. a. any substitution or processing of output, should occur when you output the data, not when you store the data. b. if you have a need to store data containing sql special characters, quotes in this case, you would apply any escape_string() function or even better yet, simply use a prepared query, right before executing the query, not prior to content being added to the data that contains quotes.
    1 point
  2. I see in your query that you are selecting several columns named "id" When you use fetch_assoc() the column names must be unique otherwise $row["id"] will be overwritten by the last one (seller id) therefore you cannot reference the user id or catgory id etc. Use column aliases to differentiate. Now you can reference $row['pid'], $row['cid'] etc When producing output with various levels of headings and subheadings and subtotals, store your data in an array that reflects the output structure. For example... $data = [ 2 => [ 'seller_name' => 'Sasha', 'orders' => [ 10002 => [ 'lines' => [ 0 => [ 'purchase_price' => 200.00, 'uid' => 4, 'user_fullname' => 'yeewen' . . . ], 1 -> [ 'purchase_price' => 200.00, 'uid' => 4, 'user_fullname' => 'yeewen' . . . ] ] 'order_total' => 400.00 ] ], 'seller_total' = 400.00 ]; Then the processing becomes a set of nested loops... foreach ($data as $seller_id => $seller_data) { output seller heading foreach ($seller_data['orders'] as $order_no => $order_data) { output order heading foreach ($order_data['lines']) { output line data } output order subtotal } output seller subtotal accumulate grand total } output grand total
    1 point
This leaderboard is set to New York/GMT-04:00
×
×
  • 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.