First question: Yes. See the manual page on arithmetic operators. $remainder = $a % $b, just like in C.
Second question: Yes. It's in the MySQL manual under "Dumping the structure and data from MySQL databases and tables" ... and there's a utility for doing it, mysqldump. It produces sql for recreating your schema and data. Good for backups, too.