PHP:
$dbname = 'db_cart';
$sql = "SHOW TABLES FROM $dbname LIKE '%id_%' ";
$result = mysql_query($sql);
if (!$result) {
echo "DB Error, could not list tables\n";
echo 'MySQL Error: ' . mysql_error();
exit;
}
while ($row = mysql_fetch_row($result)) {
$tables="{$row[0]}";
mysql_free_result($result);
$books = mysql_query("SELECT isbn FROM books WHERE quantita > '0' ") or die(mysql_error());
// scorro con un array la query e quindi i vari campi delle varie tabelle
while($rowbooks = mysql_fetch_array($books))
{
extract($rowbooks);
mysql_query ("UPDATE $tables SET disponibile = '1' WHERE isbn = '$isbn' ORDER BY timestamp ASC ") or die(mysql_error());
mysql_query ("UPDATE books SET quantita = quantita-1 WHERE isbn = '$isbn'") or die(mysql_error());
}
}
Grazie!