I have one while loop which displays data from the database. Now I want multiply two values in one row and display the result in the same row, the same way multiply the values
Try below :
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td class='alt'>" . $row['id'] . "</td>";
echo "<td>" . $row['item'] . "</td>";
echo "<td>" . $row['amount'] . "</td>";
echo "<td>" .($row['item'] * $row['amount']). "</td>";
echo "</tr>";
}
you can try
printf('amount is %d',$row['item'] * $row['amount']);
reference
Change the query as
$result= mysql_query("Select id, item, amount, (item * amount) total
from table_name");
then in while loop
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td >" . $row['id'] . "</td>";
echo "<td>" . $row['item'] . "</td>";
echo "<td>" . $row['amount'] . "</td>";
echo "<td>" .($row['total'] "</td>";
echo "</tr>";
}
From Where you are getting $rr1
??
You can have
echo "<td>" . $row['item'] * $row['amount'] . "</td>";
Hope this is what you want...