I'm new to php and mysql, I have a database with some fields already created, the idea is to print a ticket like the supermarkets but I want to list the purchased products one by one, so I read that you could use foreach, this it's the code that I have
foreach ($datos as $productos) {
echo $productos->product_name ." x ". $productos->quantity;
}
product_name refers to the field in the bd of the names of the products and quantity the quantity.
Ideally, it would be something like:
soap x 1 potatoes x 2
And so, but I get the following error:
Notice: Trying to get property 'product_name' of non-object in
Does anyone have any ideas for this disoriented boy? thanks!