Jump to content


Photo

Determining Field Names?


  • Please log in to reply
2 replies to this topic

#1 Balmung-San

Balmung-San
  • Members
  • PipPipPip
  • Advanced Member
  • 327 posts

Posted 16 March 2006 - 12:55 AM

Alright, I'm trying to write a program that requires me to have many tables, however the tables will have varying field names and I'd like a way to dynamically find out the table names. Any way I could do this?
"Paranoia is very useful in this work. ...If your cryptographic system can survive the paranoia model, it has at least a fighting chance of surviving in the real world." - Niels Ferguson & Bruce Schneier

They say there's more then one way to skin a cat.
In programming, there's no wrong way to skin a cat, just more efficent ways of doing so.

#2 wickning1

wickning1
  • Members
  • PipPipPip
  • Advanced Member
  • 405 posts

Posted 16 March 2006 - 03:42 AM

I've never seen a problem that requires me to add tables dynamically, and I've seen a lot of problems. If you post some more details, we might be able to help you design something a little more stable.

However, you can always use SHOW commands to get whatever you need. SHOW DATABASES, SHOW TABLES, SHOW COLUMNS, etc.

#3 Balmung-San

Balmung-San
  • Members
  • PipPipPip
  • Advanced Member
  • 327 posts

Posted 17 March 2006 - 02:40 PM

I'm creating a shop system that will have different field names for each user. Each user will have a table that is equal to their username.

Could I do this?:

//connect and select_db
$sql = mysql_query("DESCRIBE ".$username);
$tables = mysql_fetch_array($sql);

"Paranoia is very useful in this work. ...If your cryptographic system can survive the paranoia model, it has at least a fighting chance of surviving in the real world." - Niels Ferguson & Bruce Schneier

They say there's more then one way to skin a cat.
In programming, there's no wrong way to skin a cat, just more efficent ways of doing so.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users