Problem in code 2

Hello everyone, I have a problem with my code. I would want to click on one single rectangle to change the color of it but every rectangle change color at the same time. Can someone help? And is there a function to give each shape a color?

this is my code.
void setup(){
size(700, 750);
background(225, 242, 228);
}

void draw(){
// rectangles
int y = 40;
while(y < 650) {
int x = 100;
while(x < 600){
stroke(0);
strokeWeight(3);
fill(value);
rect(x, y, 100, 140, 10);
if(mouseX > x && mouseX < x+100 && mouseY > y && mouseY < y+140){
strokeWeight(3);
stroke(255, 0, 0);
//fill(0);
rect(x, y, 100, 140, 10);
}
x = x + 130;
}
y = y + 170;
}
}

int value = 0;
int x = 100;
int y = 40;

void mousePressed() {
if (value == 0) {
value = 255;
} else {
value = 0;
}
}

You are redrawing all your rectangles every frame. You are redrawing them all in the same color.

The fill() function is what sets the drawing color.

But then what should I change?

You could create a 2D color array.

When you redraw the rectangles, you should first access the color from the array and use it to fill the shape.