Spawning gui buttons

So Im trying to spawn GUI buttons in a 5 by 6 grid like structure containing 30 cubes each one with k. I want square buttons with a counter K on it incrementing each one. I eventually want to make it usable for an iPhone but thats not a priority right now i just want this to work.

var j=30;
var l=30;

var k=1;

function OnGUI () {
    // Make a group on the center of the screen
    GUI.BeginGroup (Rect (Screen.width / 2 - 100, Screen.height / 2 - 100, 250, 800));
    for(var x=1; x<6; x++){
    	for(var k=1; k<7; k++){
 	   		
 	   		if(GUI.Button (Rect (j,l,20,20), "x")){
    			Application.LoadLevel (k);
    			}
    			
    		j=j+30;	
    		
    		if(j>=180){
    			j=30;
    		}
		}
    	l=l+30;
    	if(l>=210){
   			l=30;
   		}
    Debug.Log("x");   		
    }

}

Maybe you’re probably looking for something like this:

#pragma strict

var levelStart : int = 1;
var levelCount : int = 25;
var buttonWidth : int = 30;
var buttonHeight : int = 30;

private var cells : int;
private var groupRect : Rect;

function Start () {
	cells = Mathf.CeilToInt(Mathf.Sqrt(levelCount));
	groupRect = Rect ((Screen.width - buttonWidth * cells) / 2, (Screen.height - buttonHeight * cells) / 2, buttonWidth * cells, buttonHeight * cells);
}

function OnGUI () {
	// Make a group on the center of the screen
	GUI.BeginGroup (groupRect);
	var level : int = levelStart;
	var y : int = 0;
	for (var l : int = 0; l < cells; l++) {
		var x : int = 0;
		for (var c : int = 0; c < cells; c++) {
	     	if (GUI.Button (Rect (x, y, buttonWidth, buttonHeight), level.ToString())){
	        	Application.LoadLevel (level);
	        }
	        x += buttonWidth;
	        level++;
	        if (level > levelCount)
	        	break;
		}
		if (level > levelCount)
			break;
		y += buttonHeight;
 	}
 	GUI.EndGroup();
}

Yes, Thank you very much skaredCreations!