-1

i have this code which shows data from a database. the code below is from the viewer side and there is no backend and retrieval. i was wondering how i can have every different entered result as a different colour. it is like different comments. i have word wrap on i don't want every single line to be a different colour i need every new comment ill show you the code below. i am getting the data from a database and the results get inputed as a list.

   <script>
        $(document).ready(function(){
            setInterval(function() {
                $("#load_results").load("db_results.php");
            }, 1000);
        });

    </script>

<div id="aline">
        <div id = "load_results"></div>
        
        </div >

i have looked everywhere to find an answer but i can't what will i have to add to do this. i have tried multiple ways which i used to change colour but i can't seam to get it right. at this stage all i have in css is the word wrap since i can't seam to add any colour

Jack
  • 77
  • 15

1 Answers1

1

I don't know the structure of your db_results.php, but why do you not put it into a, let's say table or spans or divs or whatever and alternate the colors of each row by CSS ?

The code snippet is shown here : https://stackoverflow.com/a/3084318/1203816

Community
  • 1
  • 1
krestano
  • 136
  • 3
  • 1
    i want the colours to be random – Jack Jan 23 '16 at 09:37
  • stays the same, but you have to change the fixed background-color to something like background-color: – krestano Jan 23 '16 at 09:40
  • it sets the background-color to a random value using php's random function. If you do not have php included you can get the same by using javascript or jquery. – krestano Jan 23 '16 at 09:42