I am not completely understanding how to print out that data that you say I have already retrieved, but am eager to learn how and understand this better. I am going to show you my complete code for the queries I am using because now I am sure that I am probably making more work out of it than I need to. Here is what I have for queries:
PHP Code:
//query of % that are anchor bend and wire gauge 3 with endType Loop
$conn = mysql_connect("localhost","user","pass") or trigger_error("SQL", E_USER_ERROR);
$db = mysql_select_db("database", $conn) or trigger_error("SQL", E_USER_ERROR);
$sql="SELECT COUNT(fracture)
FROM welded_wire_ties
WHERE time between '$time1' and '$time2'
AND wireGauge = '3'
AND fracture = 'Anchor Bend'
AND endType = 'Loop;";
$result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR);
while($row = mysql_fetch_assoc($result))
{
$abcount3 = $row['COUNT(fracture)'];
}
//query of % that are break back and wire gauge 3 with endType Loop
$conn = mysql_connect("localhost","user","pass") or trigger_error("SQL", E_USER_ERROR);
$db = mysql_select_db("database", $conn) or trigger_error("SQL", E_USER_ERROR);
$sql="SELECT COUNT(fracture)
FROM welded_wire_ties
WHERE time between '$time1' and '$time2'
AND wireGauge = '3'
AND fracture = 'Break Back'
AND endType = 'Loop'";
$result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR);
while($row = mysql_fetch_assoc($result))
{
$bbcount3 = $row['COUNT(fracture)'];
}
//query of % that are weld and wire gauge 3 with endType Loop
$conn = mysql_connect("localhost","user","pass") or trigger_error("SQL", E_USER_ERROR);
$db = mysql_select_db("database", $conn) or trigger_error("SQL", E_USER_ERROR);
$sql="SELECT COUNT(fracture)
FROM welded_wire_ties
WHERE time between '$time1' and '$time2'
AND wireGauge = '3'
AND fracture = 'Weld'
AND endType = 'Loop'";
$result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR);
while($row = mysql_fetch_assoc($result))
{
$weldcount3 = $row['COUNT(fracture)'];
}
//query of total # rows that are wire gauge 3 with endType Loop
$conn = mysql_connect("localhost","user","pass") or trigger_error("SQL", E_USER_ERROR);
$db = mysql_select_db("database", $conn) or trigger_error("SQL", E_USER_ERROR);
$sql="SELECT COUNT(fracture)
FROM welded_wire_ties
WHERE time between '$time1' and '$time2'
AND wireGauge = '3'
AND endType = 'Loop'";
$result = mysql_query($sql, $conn) or trigger_error("SQL", E_USER_ERROR);
while($row = mysql_fetch_assoc($result))
{
$totalFracture3 = $row['COUNT(fracture)'];
}
I am trying to get the percentage of the following:
Anchor Bend, Wire Gauge 3, Loop End /(divided by) Total # rows that are Wire Gauge 3, Loop End
Break Back, Wire Gauge 3, Loop End /(divided by) Total # rows that are Wire Gauge 3, Loop End
Weld, Wire Gauge 3, Loop End /(divided by) Total # rows that are Wire Gauge 3, Loop End
I thought I had to query each one separately and then divide it by the total rows that are Wire Gauge 3 with a Loop End. You mentioned not needing a while loop and that I am making no distinction between fracture types. How can I do this in a cleaner and easier way?
Thanks so much for your help.
Bookmarks