PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 20th, 2012, 06:28 PM
rms730 rms730 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 7 rms730 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 23 m 15 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old December 20th, 2012, 10:50 PM
Jacques1's Avatar
Jacques1 Jacques1 is online now
pollyanna
Click here for more information.
 
Join Date: Jul 2012
Location: Germany
Posts: 1,834 Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 1 Day 1 h 44 m 46 sec
Reputation Power: 811
Hi,

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?

Reply With Quote
  #3  
Old December 20th, 2012, 11:37 PM
rms730 rms730 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 7 rms730 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 23 m 15 sec
Reputation Power: 0
Quote:
Originally Posted by Jacques1
Hi,

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.

Thanks

Reply With Quote
  #4  
Old December 21st, 2012, 05:05 AM
Jacques1's Avatar
Jacques1 Jacques1 is online now
pollyanna
Click here for more information.
 
Join Date: Jul 2012
Location: Germany
Posts: 1,834 Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 1 Day 1 h 44 m 46 sec
Reputation Power: 811
OK, I see. But this still isn't a good solution.

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.

Reply With Quote
  #5  
Old December 21st, 2012, 04:44 PM
rms730 rms730 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 7 rms730 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 23 m 15 sec
Reputation Power: 0
Quote:
Originally Posted by Jacques1
OK, I see. But this still isn't a good solution.

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.

Thanks again.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Automating database query and insert

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap