Page 1 of 1

Special SQL command?

Posted: Fri Mar 07, 2003 6:12 pm
by Jim
Hey all.

I'm trying to delete information from all tables that have the characters '_sites' in them.

The code I was TRYING to use looks like this:

Code: Select all

$sql = "delete from *_sites where site_pre = '$pre'";
Of course, that creates an error...

Any ideas on how to complete this task?

Much thanks!

Posted: Fri Mar 07, 2003 6:39 pm
by rodrigocaldeira
Just an idea...

Code: Select all

<?php
$tables = "show tables"
$result = mysql_query($tables,$connection);
$num = mysql_num_rows($result)
$i = 0;
while ($i < $num)
    {
    if (strpos(mysql_result($result,$i),"_site") !== FALSE)
          {
          mysql_query("delete * from " . mysql_result($result,$i) );
          }
    $i++;
    }

?>
I prefer to use mysql_result!!!