Hi,
I'm trying to write a custom PHP script that querys the Hikashop database and prints out the results in a list.
As an example I'm trying to target all orders of a certain product that are confirmed and then print the shipping address.
The problem is that I don't know how to target the shipping address only and with the code below I'm getting duplicate lines in the list (Presumably this is because it's printing all addresses associated with the order.)
I've managed to join the below tables together (using code from another forum post that I found) to allow me to search them but I think I should be selecting all from the order table rather than the address table. Could that be why I'm getting duplicate results?
How does the below need to change for my query to work correctly?
$result = mysqli_query($con,"SELECT *
FROM waw_hikashop_address
JOIN waw_hikashop_order
ON
waw_hikashop_address.address_user_id=waw_hikashop_order.order_user_id
JOIN waw_hikashop_order_product
ON
waw_hikashop_order.order_id=waw_hikashop_order_product.order_id
WHERE order_product_code
LIKE `3_month_subscription`
AND order_status
LIKE `confirmed`
");
I'm using the following to print out the list:
while($row = mysqli_fetch_array($result))
{
$csv_line = $row['address_title'] . ", " . $row['address_firstname'] . ", " . $row['address_lastname'] . ", " . $row['address_post_code'] . ", " . $row['order_product_name'] . ", " . $row['order_payment_method'] . ", " . $row['order_number'] . ";";
echo $csv_line;
};