Hello,
I have a sql database which contains the names and descriptions of a product and the price. However, all products have a starting price of 5 and then the value of the product itself is added. THey also have a multiplier.
eg. if a price is 210.13 dollars, the administration cost needs to be added so the price becomes 215.13 dollars. Then it has to be multiplied by 1.85 so the new price will be: 397,99. The prices also need to be rounded per 5 dollars and always up. So in this case, the final price will be 400. I already got that function, but it only seems to work for one column...
Now I could calculate that manually, but as there are many products... I am looking for a way to do that with php.
Lemme first give my code:
<table width="100%" border="0" rules="groups" table class="table">
<thead>
</thead>
<tbody>
HTML;
while ($row = mysql_fetch_assoc($result)){
$row['price'] = round ((($row['price']+5) *1.85),0);
$base_m=5;
$row['price1'] = $base_m*(ceil(($row['price'])/$base_m));
echo <<<HTML
<tr>
<td align="center" width="25%"><img src={$row['thumb_name']}><br>
{$row['name']}<br>
{$row['description']}<br />
{$row['price']}<br></td>
<td align="left" width="0%"></td>
HTML;
$row = mysql_fetch_assoc($result);
if (!$row){
echo "<td> </td><td> </td>";
} else {
echo <<<HTML
<td align="center" width="25%"><img src={$row['thumb_name']}><br>
{$row['name']}<br>
{$row['description']}<br />
{$row['price']}<br></td>
<td align="left" width="0%"></td>
HTML;
}
$row = mysql_fetch_assoc($result);
if (!$row){
echo "<td> </td><td> </td>";
} else {
echo <<<HTML
<td align="center" width="25%"><img src={$row['thumb_name']}><br>
{$row['name']}<br>
{$row['description']}<br />
{$row['price']}<br></td>
<td align="left" width="0%"></td>
HTML;
$row = mysql_fetch_assoc($result);
if (!$row){
echo "<td> </td><td> </td>";
} else {
echo <<<HTML
<td align="center" width="25%"><img src={$row['thumb_name']}><br>
{$row['name']}<br>
{$row['description']}<br />
{$row['price']}<br></td>
<td align="left" width="0%"></td>
HTML;
}
} //end if
echo "</tr>";
} //end while
echo <<<HTML
</tbody>
<tfoot>
<tr>
<p><th colspan="4">
$pageNavBar
</th>
</tr>
</tfoot>
</table>
I added a function to get the price from the database and then add the administration fee and then add the multiplier. However, this function only seems to work for the first column. The others won't display any price.
Does anybody know how to fix this? Am I doing something wrong? I also tried adding the same line in again and renaming the function (to price2 with same calculation), but that also dosen't work. Do I need to apply the function for all columns for it work or something?
I'd be grateful if somebody can help me out, I really don't see it, nor can I find anthing on the web. Been searching endlessly for days now.
thanks!