Here's what I am trying to do:
If you do a while or for loop, is possible to create a variable for individual values?
For example, if I employed a loop to pull out all the cities in an address table, is it then possible to take the result and then be able to create something like $atlanta or $macon or $augusta.
From my limited experience I can get the loop to output everything but all I know is to echo those results. My goal is to use each variable for math in a different table cells. Currently all I can accomplish is putting them all in one cell b/c the echo is doesn't allow me to put <table>'s, <tr>'s and <td>'s between results.
MY gut tells me I should be using some kind a array with a foreach or while loop.
Below is how I was able to achieve what I wanted: I actually have 40 queries on my database with each query producing the variable I need to use in the table.
This is the end result: http://whitealbumregistry.com/stats.php
$dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME)
or die('Error connecting to MySQL server');
$query1 = "SELECT * FROM whitealbumreg.lps";
$result1 = mysqli_query($dbc, $query1)
or die('Error querying database.');
$query2 = "SELECT * FROM whitealbumreg.lps WHERE lp_origin='uk'";
$result2 = mysqli_query($dbc, $query2)
or die('Error querying database.');
$query3 = "SELECT * FROM whitealbumreg.lps WHERE lp_origin='us'";
$result3 = mysqli_query($dbc, $query3)
or die('Error querying database.');
....
$lps = mysqli_num_rows($result1);
$uk = mysqli_num_rows($result2);
$us = mysqli_num_rows($result3);
echo "<br />\n";
echo "<table width='616' border='0' cellpadding='2'>\n";
// New Row
echo "<tr>\n";
echo " <td>\n";
echo " <table width='607' border='1' cellpadding='2'>\n";
echo " <tr>\n";
echo " <td><font size='4'>Registered copies of the Beatles White Album</font></td>\n";
echo " <td class='center' width='30'>Total</td>\n";
echo " <td class='center' width='35'>Percent</td>\n";
echo " <td class='center' width='120'>Percent of Total Release*</td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td>UK</td>\n";
echo " <td class='center'>" . $uk . "</td>\n";
echo " <td class='center'>" . round(($uk / $lps) * 100) . "%" . "</td>\n";
echo " <td class='center'>" . (($uk / 100000) * 100) . "%" . "</td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td>US</td>\n";
echo " <td class='center'>" . $us . "</td>\n";
echo " <td class='center'>" . round(($us / $lps) * 100) . "%" . "</td>\n";
echo " <td class='center'>" . (($us / 3200000) * 100) . "%" . "</td>\n";
echo " </tr>\n";
echo " </table>\n";
echo " <table width='607'>\n";
echo " <tr>\n";
echo " <td class='right'>* - based on 3,200,000 US and 100,000 UK copies</td>\n";
echo " </tr>\n";
echo " </table>\n";
echo " </td>\n";
echo "</tr></table>\n";
echo "<table width='600' border='0' cellpadding='2'>\n";
//new row
echo " <tr><td>\n";
echo "<table width='300' border='1' cellpadding='2'>\n";
echo " <tr>\n";
echo " <td>UK: Side vs. Top Load</td>\n";
echo " <td class='center' width='30'>Total</td>\n";
echo " <td class='center' width='35'>Percent</td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td>Side</td>\n";
echo " <td class='center'>" . $side . "</td>\n";
echo " <td class='center'>" . round(($side / $uk) * 100) . "%" . "</td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td>Top</td>\n";
echo " <td class='center'>" . $top . "</td>\n";
echo " <td class='center'>" . round(($top / $uk) * 100) . "%" . "</td>\n";
echo " </tr>\n";
echo "</table>\n";