Php / Mysql While Loop Error
<p>Okay, none of those responses I used but I fixed it myself.</p>

<p>Im having trouble though trying to sum up all the prices for the books:</p>

<p>Code:</p>

<pre><code>&lt;style type="text/css"&gt;
table{font-size:1.11em;}
tr{background-color:#eee; border-top:1px solid #333;}
&lt;/style&gt;
&lt;?php
$con = mysql_connect("localhost","root","pass");
if (!$con)
{
    die('Could not connect: ' . mysql_error());
}

mysql_select_db("bookorama", $con);

$sql="SELECT customers.name, books.title, books.isbn, books.price 
         FROM customers, orders, order_items, books
         WHERE customers.customerID = orders.customerID 
         AND orders.orderID = order_items.orderID 
         AND order_items.isbn = books.isbn;";

$result = mysql_query($sql);     // You actually have to execute the $sql with mysql_query();
if($result === FALSE) {
    die(mysql_error()); // TODO: better error handling
}
echo "&lt;h1 style='color:#3366ff;'&gt;Each customer book orders&lt;/h1&gt;";
echo "&lt;table&gt;";  //start the table

while($row = mysql_fetch_array($result, MYSQL_ASSOC))  //Loop through the results
{
    //echo each row of the table
    echo "&lt;tr&gt;";              
    echo "&lt;th&gt;&lt;strong&gt;Customer Name:&lt;/strong&gt;&lt;br&gt;&lt;/th&gt;";               
    echo "&lt;td&gt;$row[name]&lt;/td&gt;";       
    echo "&lt;th&gt;&lt;strong&gt;Book Title&lt;/strong&gt;&lt;br&gt;&lt;/th&gt;";                
    echo "&lt;td&gt;$row[title]&lt;/td&gt;";
    echo "&lt;th&gt;&lt;strong&gt;ISBN&lt;/strong&gt;&lt;br&gt;&lt;/th&gt;";  
    echo "&lt;td&gt;$row[isbn]&lt;/td&gt;";
    echo "&lt;th&gt;&lt;strong&gt;Book Price&lt;/strong&gt;&lt;br&gt;&lt;/th&gt;";  
    echo "&lt;td&gt;$row[price]&lt;/td&gt;";
    echo "&lt;/tr&gt;";
} 

echo '&lt;/table&gt;';   //close out the table

?&gt;
</code></pre>
