Push Button Activated While Loop

Something like this?

buttonState = digitalRead(buttonPin);

while(buttonState == HIGH)
{
// do something
}

here the while loop "do something" if the button is presed and stop if u realease the button

but if u whant to do the while loop once

int state = 0;
buttonState = digitalRead(buttonPin);

while(buttonState == HIGH && state == 0)
{
    int = 1;
// do something
} 

while(buttonState == LOW && state == 1)
{
    int = 0;
// do something or nothing xD
}

something like this? xD u can use "if" instead of "while"