ArizonaJohn Posted June 16, 2009 Share Posted June 16, 2009 Hello, The code below prints out all tables in a database called "feather" that contain "$entry" in a column called "site." Every table in "feather" has a column called "site." This code works great. However, I would like to add something. Every table in "feather" also contains a column called "votes_up." For each table that has "$entry" in it, I would like to print out the value for the "votes_up" column that corresponds to $entry. How do I go about doing this? Thanks in advance, John $result = mysql_query("SHOW TABLES FROM feather") or die(mysql_error()); while(list($table)= mysql_fetch_row($result)) { $sqlA = "SELECT COUNT(*) FROM `$table` WHERE `site` LIKE '$entry'"; $resA = mysql_query($sqlA) or die("$sqlA:".mysql_error()); list($isThere) = mysql_fetch_row($resA); if ($isThere) { $table_list[] = $table; } } foreach( $table_list as $key => $value){ echo "$value <br />"; } Link to comment https://forums.phpfreaks.com/topic/162424-pulling-a-column-value-from-an-array-of-table-names/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.