"SELECT * FROM table PERCENTAGE $per"
Since you stipulate that $per is a variable name I can safely say that your SQL query is failing because it's invalid.
Perhaps you mean something like:
SELECT * FROM table PERCENTAGE WHERE per=$per
Not enough in your code sample to be sure and assuming per is an int
Resolve that and let's go on from there, if necessary.