Jump to content

Code To Loop Through Tables And Execute Query


JustinK101

Recommended Posts

<?php

  // connect to and select database.

  if ($result = mysql_query("SHOW_TABLES")) {
    if (mysql_num_rows($result)) {
      while ($table = mysql_fetch_row($result)) {
        if (mysql_query("DELETE FROM {$table[0]} WHERE deleted = 1")) {
          echo "Row deletd from {$table[0]}<br />";
        }
      }
    }
  }

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.