PDA

View Full Version : Echo tables which contain the column userid


JMH11788
02-03-2007, 06:26 PM
I'm trying to write a code which reads the tables in the database and then reads the columns within those tables. If the table has a column "userid" then I want to echo the table name.

I've tried a bunch of different things and get mixed results.

Here is where I stand right now:

$table = $vbulletin->db->query("SHOW tables");
while ($row = mysql_fetch_object($table)) {
foreach($row as $key=>$value):
$query = $vbulletin->db->query("SHOW COLUMNS FROM "."".$value."");
while ($row2 = mysql_fetch_object($query)) {
foreach($row2 as $key2=>$value2):
if ($value2 = 'userid') {
print $value." = ".$value2."<br>";
}
endforeach;
}
endforeach;
}

Any help is greatly appreciated.

Thanks!

EDIT: Nevermind, I got it working!