Special SQL command?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Jim
Forum Contributor
Posts: 238
Joined: Fri Apr 19, 2002 5:26 am
Location: Near Austin, Texas

Special SQL command?

Post 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!
rodrigocaldeira
Forum Commoner
Posts: 27
Joined: Wed Mar 05, 2003 6:40 pm
Location: Brazil
Contact:

Post 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!!!
Post Reply