Hi. I wrote a simple script to grab information out of a database for ips on my home network. Right now my page just grabs every row, every column from the db and prints it in a html table.. very simple. Now I want to make it alittle more complicated but easier for the user. Every ip has a user assigned to it.. instead of listing one large table, I want the php script to make a new table for each user. How would I even start something like this? My columns are:
id ip hostname device_name mac rule user
sample data:
2.2.2.2 testadfadfs testadsf test arp -i br0 -s 2.2.2.2 00:16:3E:7A:14:38 matt
So you see I have multiple rows with user as "matt". I am thinking I could just make several sql queries/and loops in my php file for each user, but I am going to be adding more users/device sections as I go and I would like this to be automatic.
PHP/Mysql question
Moderator: General Moderators
Re: PHP/Mysql question
what is the reasoning behind this? unless you have billions of rows per user, sharding isn't worth the effort.I want the php script to make a new table for each user
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: PHP/Mysql question
I assume by "new table" you mean a new HTML table and not a new database table? You do this in the query:
To normalize, you should have a users table with usernames and unique ids, and then user in the other table would just be the id.
Code: Select all
SELECT * FROM `table_name` WHERE `user` = 'matt'mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Re: PHP/Mysql question
duh... I guess I should try to keep in mind most posts here are written by amateurs (no offense to anyone).assume by "new table" you mean a new HTML table and not a new database table?