ArizonaJohn Posted February 12, 2009 Share Posted February 12, 2009 Hello, The code below works just fine. However, I would like to use the variable "$result" where the table name "tractors" appears. How do I do this? (It doesn't work if I just type $result where tractors appears.) I am using MySQL server version 5.0.45-log. Thanks, John $result=mysql_query("SHOW TABLES FROM sand2 LIKE '%$find%'") or die(mysql_error()); $data = mysql_query("SELECT * FROM tractors") or die(mysql_error()); $info = mysql_fetch_array( $data ); while($info = mysql_fetch_array( $data )) { Print $info['site'] . " <br>"; } Quote Link to comment https://forums.phpfreaks.com/topic/144884-using-a-variable-for-a-table-name/ Share on other sites More sharing options...
aschk Posted February 12, 2009 Share Posted February 12, 2009 Of course not... $result is a "resource" type. If you want the actual data from that query you'll need to use any of the mysql_fetch_* functions to pull the data from that query. Anyway you'll want to do a query using the INFORMATION_SCHEMA tables, not using the "SHOW TABLES" cmd. Quote Link to comment https://forums.phpfreaks.com/topic/144884-using-a-variable-for-a-table-name/#findComment-760389 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.