How can I get the foreign keys of a table in mysql

Simple way to get foreign keys for given table:

SELECT
    `column_name`, 
    `referenced_table_schema` AS foreign_db, 
    `referenced_table_name` AS foreign_table, 
    `referenced_column_name`  AS foreign_column 
FROM
    `information_schema`.`KEY_COLUMN_USAGE`
WHERE
    `constraint_schema` = SCHEMA()
AND
    `table_name` = 'your-table-name-here'
AND
    `referenced_column_name` IS NOT NULL
ORDER BY
    `column_name`;

The INFORMATION_SCHEMA database contains details of the full schema of all other databases, including constraints:

http://dev.mysql.com/doc/refman/5.0/en/information-schema.html

You can also run a SHOW CREATE TABLE query to get the SQL to create a table, including its constraints.