cdoggg94 Posted December 7, 2011 Share Posted December 7, 2011 I think that I am in way over my head here... What I want is a connection to a bunch of tables at once. (eg: name1_tbl, name2_tbl name3_tbl...etc....) I want to get those names without the "_tbl" from a different table that displays them like this: name1, name2, name3...etc. I THINK i want the end output to be something like this: <?php $name1 = mysql_query = ('SELECT* FROM name1_tbl ORDER BY user_id DESC'); $name2 = mysql_query = ('SELECT* FROM name2_tbl ORDER BY user_id DESC'); $name3 = mysql_query = ('SELECT* FROM name3_tbl ORDER BY user_id DESC'); // for how ever many there are ?> i just dont know how to get to that point, and dont want to add them manually when a new person and table is added.. I dont know if this makes any sense...if anyone could help it would be much appreciated.. Link to comment https://forums.phpfreaks.com/topic/252673-dynamic-table-names/ Share on other sites More sharing options...
The Little Guy Posted December 7, 2011 Share Posted December 7, 2011 why are you making a table for each person? Link to comment https://forums.phpfreaks.com/topic/252673-dynamic-table-names/#findComment-1295336 Share on other sites More sharing options...
Pikachu2000 Posted December 7, 2011 Share Posted December 7, 2011 That indicates poor database design. There is no reason to create a new table for each new person/user. Link to comment https://forums.phpfreaks.com/topic/252673-dynamic-table-names/#findComment-1295337 Share on other sites More sharing options...
cdoggg94 Posted December 7, 2011 Author Share Posted December 7, 2011 I want to display one one page, side by side, certain things from each user. So like.. <table width="159" border="0"> <tr> <td colspan="3" >Name</td> </tr> <tr> <th >Website</th> <th >Priority</th> <th >Status</th> </tr> <tr> <td > </td> <td > </td> <td > </td> </tr> </table> My issue with all users being in the same table is that I want the table above to repeat for each user... In my head creating a table for each user when the user was created was a good way to do that. Link to comment https://forums.phpfreaks.com/topic/252673-dynamic-table-names/#findComment-1295343 Share on other sites More sharing options...
cdoggg94 Posted December 7, 2011 Author Share Posted December 7, 2011 each table was going to be displayed like this is the username from the log in == ""name1"{ display the content from name1_tbl } and repeat.. Link to comment https://forums.phpfreaks.com/topic/252673-dynamic-table-names/#findComment-1295346 Share on other sites More sharing options...
cdoggg94 Posted December 7, 2011 Author Share Posted December 7, 2011 if the username from the log_tbl in == "name1"{ display the content from name1_tbl } and repeat.. Link to comment https://forums.phpfreaks.com/topic/252673-dynamic-table-names/#findComment-1295347 Share on other sites More sharing options...
cdoggg94 Posted December 7, 2011 Author Share Posted December 7, 2011 sorry my typing right now is horrible.. if the username from the login_tbl == "name1"{ display the content from name1_tbl } and repeat.. Link to comment https://forums.phpfreaks.com/topic/252673-dynamic-table-names/#findComment-1295348 Share on other sites More sharing options...
The Little Guy Posted December 7, 2011 Share Posted December 7, 2011 create 2 tables, one for the users, and one for each website. The users table would have a user id and info about each user and a unique id. The website table would have a unique website id and who owns it along with the status and priority. something like this: <?php $sql = mysql_query("select * from users u left join websites w on(u.userid = w.userid)"); $users = array(); while($row = mysql_fetch_assoc($sql)){ $users[$row['userid']][] = $row; } print_r($users); ?> Link to comment https://forums.phpfreaks.com/topic/252673-dynamic-table-names/#findComment-1295349 Share on other sites More sharing options...
cdoggg94 Posted December 7, 2011 Author Share Posted December 7, 2011 Alright...I am going to try something like that... I think your right, I was making it wayyyy more complicated then it needed to be.... Thanks a lot for the help. Link to comment https://forums.phpfreaks.com/topic/252673-dynamic-table-names/#findComment-1295355 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.