I am creating a site for ordering pizza for my education project. With the stackoverflow community, I have already achieved a lot - so thanks! But now I am stuck and cannot find any working solution for my problem.
Question
How to change alternating row color (white / gray / white / gray ...) depending on ordernumber in the database (mysqli)? ordernumber can be on more than one line, so I cannot just change the color in a row after line.
I tried with jquery, but this only works if the order numbers are always on the list (even / odd) ... if the order is canceled, then it no longer works (see image with missing order number 7)
Here is the code in jquery:
$(document).ready(function() { var check = 0; for(var i =0; i<= $("tr").length;i++){ $("tr").each(function(){ if(parseInt($(this).find("#bestnr").text())==check){ if(check%2 == 0){ $(this).css("background-color","white"); }else{ $(this).css("background-color","#DCDCDC"); } } }); check +=1; } });
Any ideas? Thank you for your help!
source share