Temporary tables work differently and have certain advantages for example:
from the mySql manual:
You can use the TEMPORARY keyword when creating a table. A TEMPORARY table is visible only to the current connection, and is dropped automatically when the connection is closed. This means that two different connections can use the same temporary table name without conflicting with each other or with an existing non-TEMPORARY table of the same name. (The existing table is hidden until the temporary table is dropped.) To create temporary tables, you must have the CREATE TEMPORARY TABLES privilege.
You don't need PHP code but rather the correct SQL for creating a temp table: look here
basic example:
CREATE TEMPORARY TABLE myTempTable(
ID INT NOT NULL AUTO_INCREMENT,
PRIMARY KEY(id),
myField1 VARCHAR(30),
myField2 INT);
Bjom