Jump to content

dynamic table names


cdoggg94

Recommended Posts

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

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.

 

post-110186-13482403123399_thumb.jpg

Link to comment
https://forums.phpfreaks.com/topic/252673-dynamic-table-names/#findComment-1295343
Share on other sites

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.