Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7753793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:08:32+00:00 2026-06-01T12:08:32+00:00

$banana=0; $view = mysql_query(‘SELECT ……’) or die (‘Encountered an error.’) ; while($rows3=mysql_fetch_array($view)) { $total_price2=$rows3[‘qty’]*$rows3[‘number’];

  • 0
$banana=0;
$view = mysql_query('SELECT ......') or die ('Encountered an error.') ;
while($rows3=mysql_fetch_array($view))
{
    $total_price2=$rows3['qty']*$rows3['number'];
    $banana = $banana + 1;

    if ($total_price2!=0)
    {   
        if ($banana %2 ==0)
        {   
            echo "<tr class=\"alt\">";
        }   
        else
        {
            echo "<tr>";
        }   
        echo "<td>".$rows3['member']."</td>";
        echo "<td>".$rows3['payment']."</td>";
        echo "<td>$".number_format($total_price2,2)."</td>";                
    }

    echo "</tr>";
}   

Problems:

  • The “banana” alternates the colour of the table row (class=”alt”) by using modulus (%) to check if banana is a odd number.
  • Not Working, I see the browser is self-closing the opening <tr> tag.

eg:

<tr><td>person</td><td>data</td><td>$10.00</td></tr>

<tr class="alt"></tr> (Repeats in this fashion)

UPDATE

I have discovered that the reiterating banana always returns ODD NUMBERS: 1 , 3, 5, etc

MySQL is not running correctly

SELECT table1.member, table1.paid, table1.payment,table2.qty,table3.number FROM table1,table2,table3 WHERE table1.member = table2.member AND table1.payment="fruit"

It is giving me wrong data like so:

  1. person1 $10.00
  2. person1 $0.00
  3. person2 $10.00
  4. person2 $0.00

etc

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T12:08:33+00:00Added an answer on June 1, 2026 at 12:08 pm

    That’s not going to work. You’re only opening the table row if $total_price2!=0. It seems you should only output the closing </tr> tag inside that IF block.

    Try this instead:

    <?php
    $banana=0;
    $view = mysql_query('SELECT ......') or die ('Encountered an error.') ;
    while($rows3=mysql_fetch_array($view))
    {
        $total_price2=$rows3['qty']*$rows3['number'];
    
        if ( !$total_price2)
            continue;
    
        $banana = $banana + 1;
    
        if ($banana %2 ==0)
        {   
            echo "<tr class=\"alt\">";
        }   
        else
        {
            echo "<tr>";
        }
    
        echo "<td>".$rows3['member']."</td>";
        echo "<td>".$rows3['payment']."</td>";
        echo "<td>$".number_format($total_price2,2)."</td>";
    
        echo "</tr>";
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Why do this.. $fruit_type = banana; mysql_real_escape_string($fruit_type); $query = SELECT * FROM posts WHERE
enum Fruit { Banana, Orange, Strawberry ... ... // etc, very long enum }
For example, Dole Banana is a kind of product, it's listed under the Bananas
var fruits = [ 'apple', 'banana', 'orange' ]; how do I find what index
Say I have three tables: Fruit (Table 1) ------ Apple Orange Pear Banana Produce
member purchase fruit 1 1 apple 1 2 apple 1 3 banana 1 4
I'm looking for the function in reactive-banana that will choose from which event stream
if step.include? apples or banana or cheese say yay end
I have a couple of lists of items: specials = ['apple', 'banana', 'cherry', ...]
I have the following tuple, which contains tuples: MY_TUPLE = ( ('A','Apple'), ('C','Carrot'), ('B','Banana'),

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.