Welcome Guest, Not a member yet? Register   Sign In
Noob Question
#1

[eluser]alexandervj[/eluser]
Hi,
So I have a database thats automatically made from WordPress contact form submissions and I want to use CodeIgniter to build an app to display them, etc. The problem I'm having is the database thats created by the form submissions is in a strange format - it has a few fields (field_name, field_value, time_stamp) but the name, email, and other form fields all get saved to the field_value field. The field_name field just changes based on what they are so if its the submitter's name then the value for field_name is your-name, if its the submitter's email then the value for field_name is their email, etc.

I'm not sure how to build a model, controller, and view for this kind of data. I always have set up my databases and tables so that the field contains one kind of item (i.e. first_name, last_name, email, username, etc.).

Do you have any idea what I can do to display a spreadsheet of the submitter's names, emails, etc.?
Thanks
#2

[eluser]RobertSF[/eluser]
If I'm understanding correctly, the database could look like this?

Code:
Field Name, Field Value, Timestamp
your_name, Joe Blow, Oct 02, 2014 10:00
your_email, [email protected], Oct 02, 2014 10:00
your_name, John Smith, Oct 02, 2014 12:00
your_email, [email protected], Oct 02, 2014 13:15
your_name, Lisa Simpson, Oct 02, 2014 14:00
your_email, [email protected], Oct 02, 2014 14:00

If yes, I don't think this is specifically a Codeigniter thing. No matter what you used, you would have to untangle that and convert it to something like this:

Code:
Your Name, Your Email, Timestamp
Joe Blow, [email protected], Oct 02, 2014 10:00
John Smith, no email entered, Oct 02, 2014 12:00
no name entered, [email protected], Oct 02, 2014 13:15
Lisa Simpson, [email protected], Oct 02, 2014 14:00

It's pretty much a coding exercise that requires you to loop through the input file, assemble the record, and write it to the output file. If all records consist of the same number of lines in the input file -- that is, if everyone leaves both their names and emails and not just one or the other -- the task is much simplified. If some records consist of one lines and others of two lines in the input file, you'll have to match by the timestamp, which I would hope is the same when there are two lines per record.

There are three basic tasks here.
1.- Convert the irregular input file (the form submissions) to a regular CSV output file.
2.- Take the output file and write the records to a real database (MySQL or other).
3.- Have a view to display those records, with or without a search facility.

You could have controllers for the first two. The first wouldn't even need a model, and both would have a simple view that simply said, "Hi, operation completed successfully," or something like that.

For the third task, you'd have a full MVC, but by then, you'd have a normalized database.

I hope that helps.




Theme © iAndrew 2016 - Forum software by © MyBB