I need to loop through multiple tables in my database and then populate multidimensional arrays with their contents. The code I have at the moment is returning a MySQL error. I've tried searching around but everything I find does not match my needs.
Code
// The arrays that will hold the data we wish to collect
$ids = array();
$data = array();
// The database tables we want to search through
$databaseTables = array("table1", "table2", "table3", "table4");
for ($x = 0; $x < 4; $x++) {
// Create a new array for this table's data
$ids[] = array();
$data[] = array();
// Query the database
$query = "SELECT * FROM '$databaseTables[$x]'";
$result = @mysql_query($query) or die(mysql_error());
// Collect the data
while ($row = mysql_fetch_array($result)) {
$ids[$x][] = $row['id'];
$data[$x][] = $row['data'];
}
}
Thank you for your help.
Edit
The MySQL Error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''table1'' at line 1