Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-19-2012, 06:36 AM   PM User | #1
juslai
New Coder

 
Join Date: Jul 2012
Location: Philippines
Posts: 35
Thanks: 5
Thanked 0 Times in 0 Posts
juslai is an unknown quantity at this point
help in displaying

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

Code:
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

Code:
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

Last edited by juslai; 11-19-2012 at 06:54 AM..
juslai is offline   Reply With Quote
Old 11-19-2012, 09:53 AM   PM User | #2
Redcoder
Regular Coder

 
Redcoder's Avatar
 
Join Date: May 2012
Location: /dev/couch
Posts: 309
Thanks: 2
Thanked 46 Times in 45 Posts
Redcoder has a little shameless behaviour in the past
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)).

PHP Code:
$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++;    

__________________
For professional Hosting and Web design.....


NetEssentials.co.uk
Redcoder is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:24 AM.


Advertisement
Log in to turn off these ads.