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 8112379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T02:28:51+00:00 2026-06-06T02:28:51+00:00

Problem: To style the last row in a SQL query without using any CSS3

  • 0

Problem:

To style the last row in a SQL query without using any CSS3 selectors.

PHP code:

while ($item = mysql_fetch_assoc($itemsresult))
{
    $answer = "SELECT IID, Comment FROM betyg_answers WHERE EID = '{$EID}' AND CID = '{$item['CID']}' ORDER BY ID ASC";
    $answerresult = mysql_query($answer) or die ('Error (' . mysql_errno() . ') ' . mysql_error());
    $answer = mysql_fetch_assoc($answerresult);

    if ($answer['IID'] == $item['IID'])
    {
        $html .= '
            <tr>
                <td class="arrow" style="'.$arrow.'"><img src="./img/circle_arrow_right.png" class="arrowimage"></td>
                <td class="numbers" style="'.$numbers.'">'.$itemcounter.'.</td>
                <td class="text" style="'.$text.'">'.$item['Description'].'</td>
            </tr>
        ';
    }
    else
    {
        $html .= '
            <tr>
                <td class="arrow" style="'.$arrow.'">&nbsp;</td>
                <td class="numbers" style="'.$numbers.'">'.$itemcounter.'.</td>
                <td class="text" style="'.$text.'">'.$item['Description'].'</td>
            </tr>
        ';
    }

    $itemcounter++;
}

Last row in SQL query should instead print:

$html .= '
        <tr>
            <td class="arrow" style="'.$lastarrow.'">&nbsp;</td>
            <td class="numbers" style="'.$lastnumbers.'">'.$itemcounter.'.</td>
            <td class="text" style="'.$lasttext.'">'.$item['Description'].'</td>
        </tr>
';

Question:

What needs to be added in the while loop so it recognizes the last row and print a different code instead?

  • 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-06T02:28:53+00:00Added an answer on June 6, 2026 at 2:28 am

    Use a counter:

    $i = 0;
    $c = mysql_num_rows($itemresult);
    while ($item = mysql_fetch_assoc($itemsresult)) {
      $i++;
      if ($i == $c) {
        // This is a last row
      } else {
        // Regular row
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The problem: making a very simple style switcher with js (without inline event handling).
I have a problem understanding one style definition in Windows 8 metro apps. When
The problem I'm having is that if I base a style on a second
My problem is simple, I have the font set in the body style to
I have a question regarding the style in the iframe the problem i have
I've been having a problem creating a checklist in the style of the TouchCells
this question is about style, because i think this is a very common problem
I have a problem with IE. I have a layer that has this style
I am having a problem where the last li element in a ul is
I'm having a problem with NamedPipeServerStream - when my code reads data it's just

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.