We help IT Professionals succeed at work.
Get Started

Highlight Every Other Row

zero118
zero118 asked
on
254 Views
Last Modified: 2008-03-06
I've done this before but I can't quite remember how.  Below is an actual query from the site.  I need to highlight every other row that comes from the query with style="background-color: #fafafa;"

////// THE QUERY PART

      $m = $_POST['m'];
      $w = $_POST['w'];
      $mc = $_POST['mc'];
      $pr = $_POST['pr'];
      $pi = $_POST['pi'];
      $ma = $_POST['ma'];
      $u = $_POST['u'];
                        
      
                        $query_mem_1 = "SELECT `name`, `id`, `noreq`, `desc`, `partnum`, ";
                        if ($m == 1){ $query_mem_1 .= "`mfc`, `mfcdesc`, `mfcprtnum`, "; }
                        if ($w == 1){ $query_mem_1 .= "`lbs`, "; }
                        if ($mc == 1){ $query_mem_1 .= "`mchtime`, "; }
                        if ($pr == 1){ $query_mem_1 .= "`lstprc`, "; }
                        if ($pi == 1){ $query_mem_1 .= "`prcinc`, "; }
                        if ($ma == 1){ $query_mem_1 .= "`matcst`, "; }
                        if ($u == 1){ $query_mem_1 .= "`usdin`, "; }
                        $query_mem_1 .= "CAST(SUBSTRING(`partnum`, LOCATE('-', `partnum`) + 1) AS SIGNED) AS `sort_part` FROM `$parts_database_table` WHERE `name`=\"$n\" ORDER BY `sort_part` ASC";
                        mysql_select_db($database_name, $connection);
                        $mem_1 = mysql_query($query_mem_1, $connection) or die(mysql_error());
                        $row_mem_1 = mysql_fetch_assoc($mem_1);
                        $totalRows_mem_1 = mysql_num_rows($mem_1);

////////THE LOOP PART

if ($mem_1){
                      $numOfRows = mysql_num_rows ($mem_1);
                      for ($i = 0; $i < $numOfRows; $i++){
                      $name = mysql_result ($mem_1, $i, "name");
                        $noreq = mysql_result ($mem_1, $i, "noreq");
                        $partnum = mysql_result ($mem_1, $i, "partnum");
                      $desc = mysql_result ($mem_1, $i, "desc");
                        if ($w == 1){$lbs = mysql_result ($mem_1, $i, "lbs");}
                      if ($m == 1){$mfc = mysql_result ($mem_1, $i, "mfc");}
                        if ($m == 1){$mfcprtnum = mysql_result ($mem_1, $i, "mfcprtnum");}
                      if ($m == 1){$mfcdesc = mysql_result ($mem_1, $i, "mfcdesc");}
                        if ($u == 1){$usdin = mysql_result ($mem_1, $i, "usdin");}
                      $id = mysql_result ($mem_1, $i, "id");
                        if ($mc == 1){$mchtime = mysql_result ($mem_1, $i, "mchtime");}
                      if ($ma == 1){$matcst = mysql_result ($mem_1, $i, "matcst");}
                        if ($pi == 1){$prcinc = mysql_result ($mem_1, $i, "prcinc");}
                      if ($pr == 1){$lstprc = mysql_result ($mem_1, $i, "lstprc");}
                        $desc = htmlentities($desc);
                        $mfcdesc = stripslashes($mfcdesc);

////// THE COMES THE ACTUAL DISPLAY OF EACH ROW AND ENDING OF THE SECTION
Comment
Watch Question
This problem has been solved!
Unlock 1 Answer and 1 Comment.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE