Extracting name components of html tag

I want to create a form processing page that:

1. identifies whether or not an html form is contained in the displayed instance of the php variable $content.
2. identifies all variables in the html form
3. identify the table in which each variable is to be housed within the database

I should note that each instance of $content may contain multiple variables which may all be housed in a single table, or may each be housed in unique tables.

I was planning on using the convention tablename_variablename as the name component of each html input tag. To be clear, variablename will coincide with the table column name of for each variable.

How can I best extract the variable and table names from the displayed instance of $content?

Thanks in advance.

Last edited by rms730; December 20th, 2012 at 06:35 PM.
Reason: Bad title

why do you want to do all this? Pulling database table names from input elements from forms from variables is pretty much the strangest "solution" I've heard in a while.

What exactly are you trying to do?

I am attempting to build a site that functions as an interactive tutorial to guide a user through a project. The projects are fairly long and complex, so I've split them into sections and am displaying 1 section at a time in a slide format. I've stored these sections in a mysql table with 2 columns, slide_number and content.

Each instance of the page contains a "content" div which echos an instance of the variable "$content" which is selected based on the active slide number. When the user presses the "next" button, the page refreshes while adding 1 to the slide number that is being pulled from the database.

Now I'm trying to automate the processing of the forms within the $content variables. A given instance of the $content variable may or may not contain an html form to collect and/or display data from the user. This data is housed in various other tables.

So I want to create a procedure that:
1) identifies whether or not an html form is contained in the displayed instance of the variable $content.
2) identifies all variables in the html form
3) queries the appropriate table for each variable in order to insert/update or select the appropriate data

I should note that each instance of $content may contain multiple variables which are housed in multiple tables.

As you've probably guessed, I am brand new to all of this and I appreciate any help you can give me.

First of all, I wouldn't store the slides in the database. This only makes sense if you have a kind of CMS to dynamically create slides and edit them. In any other case, use simple template files.

Secondly, you should read up on the MVC pattern as a clean solution to pass values from the database to the templates. To cut it short: Instead of letting PHP search through HTML pages to dynamically insert values, you'd create HTML templates with placeholders. When user requests a specific page, the application takes care of fetching certain values and inserting them into the placeholders.

First of all, I wouldn't store the slides in the database. This only makes sense if you have a kind of CMS to dynamically create slides and edit them. In any other case, use simple template files.

Secondly, you should read up on the MVC pattern as a clean solution to pass values from the database to the templates. To cut it short: Instead of letting PHP search through HTML pages to dynamically insert values, you'd create HTML templates with placeholders. When user requests a specific page, the application takes care of fetching certain values and inserting them into the placeholders.

Thank you very much for your guidance. I've actually constructed a simple CMS so creating and updating slides is actually fairly easy.

I'd envisioned a MVC solution, but I simply don't seem to have the skill set to complete it. Been working hard at this for a week now and I'm not making any progress.

I've created a similar, but much smaller project. I'd really appreciate any help you could give me on it. If you are willing, would you private message me your email address and I can send you the smaller project? I assume that it would be quite easy for you. If not, I certainly understand, but please private message me regardless.