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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.