Q:

Store all RGB values in a database

What's the best way to store something like this? (one time only) in a MYSQL database?
It needs to insert all RGB values in a table.
$colors = colourArray(0, 255, $con);
function colourArray($start, $number, $con) {
    foreach(range($start,$number) as $r) {
        foreach(range($start,$number) as $g) {
            foreach(range($start,$number) as $b) {
                mysqli_query($con, 'INSERT INTO rgbcolors (r,g,b) VALUES ('.$r.','.$g.','.$b.')');
            }
        }
    }
}

This works, but it takes a very long time to finish with 1 query at a time..
Does someone know a neater way?

A:

You can insert more then one set of values at a time.
$colors = colourArray(0, 255, $con);
function colourArray($start, $number, $con) {

    $colors = array();

    foreach(range($start,$number) as $r) {
        foreach(range($start,$number) as $g) {
            foreach(range($start,$number) as $b) {
                $colors[] = '('.$r.','.$g.','.$b.')';
            }
            // this could be moved to the parent foreach if you have enough memory to allocate to this.
            mysqli_query($con, 'INSERT INTO rgbcolors (r,g,b) VALUES ' . implode(',', $colors));
            $colors = array();
        }
    }

}

