$sql = "select * from mytable"; while (@data = $sth->fetchrow()) { mkdir($data[1]) if (! -d $data[1]); }