Note that there are some explanatory texts on larger screens.

plurals
  1. POMysql duplecating results
    primarykey
    data
    text
    <p>I'm making a invoice script but my query is returning al my entries mulpiple times when i fetch them. </p> <p>this is my code:</p> <pre><code>$query = " SELECT d.Quantity, d.ProductID, p.ProductName, d.UnitPrice, d.Discount FROM customers AS c, orders AS o, order_details AS d, products AS p WHERE o.OrderID = '10248' AND o.OrderID = d.OrderID AND d.ProductID = p.ProductID "; $result = mysql_query($query); $table = ''; while($row = mysql_fetch_assoc($result)){ $table .= '&lt;tr&gt;'; $table .= '&lt;td&gt;' . $row['Quantity'] . '&lt;/td&gt;'; $table .= '&lt;td&gt;' . $row['ProductID'] . '&lt;/td&gt;'; $table .= '&lt;td&gt;' . $row['ProductName'] . '&lt;/td&gt;'; $table .= '&lt;td&gt;' . $row['UnitPrice'] . '&lt;/td&gt;'; $table .= '&lt;td&gt;' . $row['Discount'] . '&lt;/td&gt;'; $table .= '&lt;td&gt;' . (100 - $row['Discount']) / 100 * $row['UnitPrice'] . '&lt;/td&gt;'; $table .= '&lt;/tr&gt;'; } </code></pre> <p>this is, a part, of what it returns.</p> <pre><code>Quantity ProductID ProductName UnitPrice Discount Subtotal 12 11 Queso Cabrales 14.0000 0 14 10 42 Singaporean Hokkien Fried Mee 9.8000 0 9.8 5 72 Mozzarella di Giovanni 34.8000 0 34.8 12 11 Queso Cabrales 14.0000 0 14 10 42 Singaporean Hokkien Fried Mee 9.8000 0 9.8 5 72 Mozzarella di Giovanni 34.8000 0 34.8 12 11 Queso Cabrales 14.0000 0 14 10 42 Singaporean Hokkien Fried Mee 9.8000 0 9.8 5 72 Mozzarella di Giovanni 34.8000 0 34.8 12 11 Queso Cabrales 14.0000 0 14 10 42 Singaporean Hokkien Fried Mee 9.8000 0 9.8 5 72 Mozzarella di Giovanni 34.8000 0 34.8 </code></pre> <p>while it sould only return 3 entries.</p> <p>anny toughts?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload