Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jul 2012
    Location
    Philippines
    Posts
    35
    Thanks
    5
    Thanked 0 Times in 0 Posts

    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.

  • #2
    Regular Coder Redcoder's Avatar
    Join Date
    May 2012
    Location
    /dev/null
    Posts
    332
    Thanks
    2
    Thanked 47 Times in 46 Posts
    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++;    



  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •