ok this part of the code is understandable but what if i'd like to change the quantity in html and it automaticly changes the total cost. I thought it must be somekind of a submit button that refreshes the page or stmh. Anyway this is my code so far:
$select = "SELECT * FROM bertool where code=$productd";
$result = mysql_query($select)
or die("Päring ebaõnnestus");
//siin ma ei tea, mis on sinu tabeli väljade nimed 🙁
while ($row = mysql_fetch_row($result)) {
$CO=$row[0];
$NA=$row[1];
$PR=$row[3];
print "<table>\n";
print "\t<tr>\n";
echo "\t\t<td width=\"250\" height=\"14\" ><div align=\"left\"><font size=\"3\">$NA</font> </div></td>\n";
print "\t\t<td width=\"250\" height=\"14\" ><input type=\"text\" size=\"3\" name=\"qty[]\" value=\"$qty\"></td>\n";
if (empty($qty)) {
$qty = 1;
}
print "\t\t<td width=\"50\" height=\"14\"><div align=\"right\"><font size=\"3\">$HI</font> </div></td>\n";
}
$TOTAL=($PR*$qty);
print "\t</tr>\n" ;
}
}
print "\t<tr>\n";
mysql_close();
echo "\t\t<td width=\"250\" height=\"16\" ><div align=\"left\"><font size=\"3\">It will cost you:</font> </div></td>\n";
print "\t\t<td width=\"50\" height=\"14\"><div align=\"right\"><font size=\"3\"><b>$total</b></font> </div></td>\n";
"</table>\n";
But i'd like to add somewhere in the code that, when you change the quantity in the input box, then when pushing change or recalculate, it automaticly changes the value total.
Maybe its better with javascript or smth