A generalization of Ding’s construction is proposed that employs as a defining set the collection of the sth powers () of all nonzero elements in , where is prime. Some of the resulting codes are optimal or near-optimal and include projective codes over that give rise to optimal or near optimal quantum codes. In addition, the codes yield interesting combinatorial structures, such as strongly regular graphs and block designs.