PHP while($ x = mysql_fetch_array($ y))

I'm using in PHP

while($x = mysql_fetch_array($y))

I want to select and show 3 records from my MySQL DB, than make in HTML code and show next 3 records from database. How to do this?

Apart from using LIMIT 3 in sql query, you can add counter:

$c = 0;
$e = $c + 3;
while($x = mysql_fetch_array($y) && $c < $e){
...
$c++;
}

Of course you can put that into another loop that will increment the initial $c value by 3 and continue retrieving values from this query result.

$idx = 0;
$htmlStr = '<div>';
while($x = mysql_fetch_array($y)) {
    if($idx % 3 == 0 && $idx>0) {
       //here your part when 3 rows areready
       echo $htmlStr.'</div>';
       $idx = 0;
       $htmlStr = '<div>';
   }
   $idx++;
   $htmlStr .= '<p>'.implode(',',$x).'</p>';
}
if($idx % 3 == 0 ) {
       echo $htmlStr.'</div>';
}