...

View Full Version : help in displaying



juslai
11-19-2012, 07:36 AM
i have a table and it displays a bunch of data from a database table i created a new query that will multiply 2 columns of that table and put the answer of those 2 columns into a column in a table that i created in html when viewing the records instead of seeing each row of get updated to a new answer i keep seeing the first answer to my query help please i want to display all the answers not just the first answer


SELECT fuel_details_price*fuel_details_liters AS amount
FROM tbl_fuel_details
ORDER BY tbl_fuel_details.id_fuel_details that is my query it displays in a row the answers but it will not display in the table accordingly


for ($i = 1; $i <= $row_fuel = mysql_fetch_assoc($fuel); $i++)
{
echo "<tr>";
echo "<td>$i</td>";
echo "<td>" . $row_fuel['fuel_details_date'] . "</td>";
echo "<td>" . $row_fuel['fuel_details_price'] . "</td>";
echo "<td>" . $row_fuel['fuel_details_liters'] . "</td>";
echo "<td>" . $row_amount['amount'] . "</td>";
echo "<td>" . $row_fuel['fuel_details_po_no'] . "</td>";
echo "<td>" . $row_fuel['fuel_details_previous_bal'] . "</td>";
echo "<td>" . $row_fuel['fuel_details_hobo'] . "</td>";
echo "<td>" . $row_joinfueltruck['truck_plate_no'] . "</td>";
echo "<td>" . $row_joinfuelfuelsource['fuel_source_name'] . "</td>";
echo "</tr>";

} my code for display it to a table in html

Redcoder
11-19-2012, 10:53 AM
I don't know your queries for fetching the other rows like $row_fuel['fuel_details_date'], but try the below code. You can't use relational operators on an object (mysql_fetch_assoc($fuel)).


$i = 0;
while( $row_fuel = mysql_fetch_assoc($fuel))
{
echo "<tr>";
echo "<td>$i</td>";
echo "<td>" . $row_fuel['fuel_details_date'] . "</td>";
echo "<td>" . $row_fuel['fuel_details_price'] . "</td>";
echo "<td>" . $row_fuel['fuel_details_liters'] . "</td>";
echo "<td>" . $row_amount['amount'] . "</td>";
echo "<td>" . $row_fuel['fuel_details_po_no'] . "</td>";
echo "<td>" . $row_fuel['fuel_details_previous_bal'] . "</td>";
echo "<td>" . $row_fuel['fuel_details_hobo'] . "</td>";
echo "<td>" . $row_joinfueltruck['truck_plate_no'] . "</td>";
echo "<td>" . $row_joinfuelfuelsource['fuel_source_name'] . "</td>";
echo "</tr>";

$i++;
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum