Hello all
I have 3 tables to join but only want to sum one column from one table
my tables are forms, filters, and options
the column i want to sum is in the forms table and is named element_5
the column in the filter table is filter_keyword and the column in the options table is option_id
so element_5 in the forms table is a price. I have a filter to choose what I want to see, ie, service type, truck used, date, and a few others that populate the filter table when I apply the filter. then I just want to sum the price for that filter.
Making any sense? let me know
here is the code im trying, but it doesn't work
$query = "SELECT * from form_10556
INNER JOIN element_options
ON form_10556.element_6 = element_options.option_id
INNER JOIN form_filters
ON element_options.option_id = form_filters.filter_keyword";
$params = array($element_5,$element_6,$option_id,$filter_keyword);
$sth = do_query($query,$params,$dbh);
while ($row = do_fetch_result($sth)) {
$totalPrice += $row['element_5'];
}