Finding the table_name without using mysql_table_name?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Matt Phelps
Forum Commoner
Posts: 82
Joined: Fri Jun 14, 2002 2:05 pm

Finding the table_name without using mysql_table_name?

Post by Matt Phelps »

Is there a simple way of retrieving the name of the table that you are doing a data query from?

My script pulls data from a table and puts it into a form so that the data can be edited and then resubmitted back to the database using UPDATE. The table that it gets the original data from is specified as a variable in the script URL ie; http://localhost/edit.php?table=tableone etc

Once the data has been edited in the form then I want it to go back into the table 'tableone' but the 'tableone' variable no longer exists because the script has already be executed once, so I can't use that variable.

Not sure I am describing this very well. :(

Anyway I tried using the mySQL table_name function along with list_tables but you have to give a index number for that function and the number of tables in the database can vary and often changes so that isn't much help.

Hmmm.......

Anyone got any idea what I'm talking about here!?
fatalcure
Forum Contributor
Posts: 141
Joined: Thu Jul 04, 2002 12:57 pm
Contact:

Post by fatalcure »

umm yea, you can just do this:

in your form just add a hidden field like so:

Code: Select all

<input type='hidden' name='tablename' value='<?php echo $tablename; ?>'>
so now even after a submit, you'll still have the variable $tablename to use.
Post Reply