Forum Moderators: coopster
I have the code below, that gives the prices 2 things.
however i want to add up the values of row 1 so i want price1 + price2 of row1.
how can i do this
hope you can help
thanks in advance
if($nrows1!= 0)
{
print "<table border=20>
<tr>
<th>price 1
<th>price 2\n";
for($j=0; $j<$nrows1; $j++)
{
$row = pg_fetch_array ($result1);
printf ("<tr> <td>%s</td>
<td>%s</td>
</tr>", $myrow['price1'], $myrow['price2']);
print "<tr><td>" . $row["price1"];
print "<td>" . $row["price2"];
print "\n";
}
print"</table>\n";
printf("</form>");
}
i want to add the price of adults + child+ student, and then put it in a variable called total so it can be displayed.
how would i do this.
thanks in advance.
if($nrows1!= 0)
{
print "<table border=20>
<tr>
<th>Adult Price (£)
<th>Child Price (£)
<th>Stutent Price(£)\n";
for($j=0; $j<$nrows1; $j++)
{
$row = pg_fetch_array ($result1);
printf ("<tr> <td>%s</td>
<td>%s</td>
<td>%s</td>
</tr>", $myrow['adultprices'], $myrow['childprices'], $myrow['studentprices']);
print "<tr><td>" . $row["adultprices"];
print "<td>" . $row["childprices"];
print "<td>" . $row["studentprices"];
print "\n";
}
print"</table>\n";
printf("</form>");
}
printf ("<tr> <td>%s</td>
<td>%s</td>
<td>%s</td>
</tr>", $myrow['adultprices'], $myrow['childprices'], $myrow['studentprices']);
print "<tr><td>" . $row["adultprices"];
print "<td>" . $row["childprices"];
print "<td>" . $row["studentprices"];
This is the solution:
printf ("<tr> <td>%s</td>
<td>%s</td>
<td>%s</td>
<td>%s</td>
</tr>",
$myrow['adultprices'],
$myrow['childprices'],
$myrow['studentprices'],
$myrow['adultprices']+$myrow['childprices']+$myrow['studentprices']
);
How do i pass this down to the row[""] so it actually does it for each row
$myrow['adultprices']+$myrow['childprices']+$myrow['studentprices']