Welcome Guest, Not a member yet? Register   Sign In
Help Finding and Example of Generating an HTML Report
#1

[eluser]bt101[/eluser]
Hi

I have setup a database and Grocery CRUD so that I can enter information into the database. I am very impressed with it. I now need to move on the the next step where I get information out of the database.

I want to generate several HTML reports where:
1. The user is presented with a form where they enter the information that will be used to search the database.
2. The user hits SUBMIT.
3. The code does SQL commands with a bunch of selects/joins etc.
4. The resulting table is displayed on the screen (doesn't have to be fancy).

I would think that this is a very basic/common WEB task, however I can't find an example for codeigniter.
Can someone direct me to an example please?

I can do this in PHP but am not even sure if codeigniter is suitable for something so simple.

Also, is it appropriate to take my current directory structure that contains all the Grocery CRUD stuff and add to it to create the above reports of which I speak, or should I create a completely separate directory structure (a fresh codeigniter install) to perform these reports? I'm just worried that I'm going to mess up my hard-fought Grocery CRUD setup.

Thanks.
#2

[eluser]Otemu[/eluser]
Hi,

Quote:I have setup a database and Grocery CRUD
Did you use codeigniter to do this or just standard PHP?

If it the case you used standard PHP and don't really have any knowledge using codeigniter then take a look at the codeigniter user guide here

Then you should probably follow some tutorials on tut+ here and you should have enough to implement what you want to do.
#3

[eluser]bt101[/eluser]
[quote author="Otemu" date="1402482640"]Hi,

Quote:I have setup a database and Grocery CRUD
Did you use codeigniter to do this or just standard PHP?

.[/quote]

For the database I created the tables with phpmyadmin.
For Grocery CRUD, I:
1. downloaded and extracted codeigniter
2. downloaded and extracted Grocery CRUD
3. I believe the only thing that needed modification in GC was the controller

The thing that I need now (present a form and then present a table with the results) has to be the most common thing that is done on the web, but I can't seem to find an example in codeigniter. I must be searching for the wrong terms. All of the examples and tutorials that I have seen, show how to setup a model/view/controller and the result is the user points their URL to one address and it returns a what is virtually a simple dump from one table. I mean, if I wanted that, I could just login to a mysql client and execute a simple SQL statement to get a dump from a table.

I want the user to first be presented with a form to enter the various search info. When they hit SUBMIT In then need code to do joins etc of various tables to produce and HTML output of the results.

I'm hoping there is an example, or perhaps let me know if codeigniter is not suitable for such a thing.

Thanks
#4

[eluser]Otemu[/eluser]
Hi,


Quote: have seen, show how to setup a model/view/controller and the result is the user points their URL to one address
From what I have seen of a brief look at Grocery CRUD, that is exactly what your have to do

Quote:I want the user to first be presented with a form to enter the various search info
Create a controller to handle this, which will contain the validation and a view which will contain your form and where it posting too
url example yoursite.com/customstuff/displayform

Quote:When they hit SUBMIT In then need code to do joins etc of various tables to produce and HTML output of the results
Create a controller to process the form, model queries database and view to display results.
form will be submitted to yoursite.com/customstuff/displayresults

May need to look at routes also in the codeigniter guide so that you can hit your custom url or maybe something about it in the Grocery CRUD.

That answer is based mainly on codeigniter way of doing things, I have not worked with Grocery CRUD, You could ask the question on there forum there probably give you a more accurate response here

Hope that helps
#5

[eluser]CroNiX[/eluser]
So, you're saying you don't know how to create an HTML table?
#6

[eluser]bt101[/eluser]
[quote author="CroNiX" date="1402583676"]So, you're saying you don't know how to create an HTML table?[/quote]

huh?

Do you have a link to an example of search form as requested?
#7

[eluser]bt101[/eluser]
Quote:
May need to look at routes also in the codeigniter guide so that you can hit your custom url or maybe something about it in the Grocery CRUD.

Thanks for the help.
I really never should have mentioned Grocery CRUD because it has nothing to do with my query. I only mentioned Grocery CRUD to indicate that I now have successfully put information into a database.

Let's take Grocery CRUD completely out of the picture and just say that I have a populated database.

I know I am going to have difficulty trying to explain this...

You mention above:

Create a controller to process the form, model queries database and view to display results.
form will be submitted to yoursite.com/customstuff/displayresults


This is what I am finding in all of the examples. They give instructions on how to setup the MVC and then say "point your url at this link and voila, out comes the results".

What I am not getting is there must be some interaction/flow:
1. user is presented with search form
2. when the user hits submit, the info from the search form is collected and passed to code that gets info from the database.
3. The database is searched and the results are displayed.

From all of the examples, I am only getting that last step (step3).

I can't tell the users... "Here is a url, and that is the only thing that I can provide to you. You must enter that url into your browser and out comes some results (the results likely won't be what you are seeking because you were not able to enter any information for a search)".

If I could just find one example of that flow I would be set.
I must be searching for the wrong terms because I keep coming back to those examples that just illustrate using one url to get what amounts to simple dump of a table.
#8

[eluser]CroNiX[/eluser]
[quote author="bt101" date="1402619024"][quote author="CroNiX" date="1402583676"]So, you're saying you don't know how to create an HTML table?[/quote]

huh?

Do you have a link to an example of search form as requested?[/quote]
Sure, strangely enough, they have several examples of some of what you want to know in that thing called a user guide.

Creating Forms: http://ellislab.com/codeigniter/user-gui...elper.html
Form Validation: http://ellislab.com/codeigniter/user-gui...ation.html
Creating a HTML table from database results: http://ellislab.com/codeigniter/user-gui...table.html
CI General Tutorial: http://ellislab.com/codeigniter/user-gui...index.html

CI is a framework and you need to build what you want to do. There probably isn't a step by step guide for your specific use case, but you can piece just about all of it together by reading the user guide.
#9

[eluser]bt101[/eluser]
[quote author="CroNiX" date="1402623716"]
Sure, strangely enough, they have several examples of some of what you want to know in that thing called a user guide.

Creating Forms: http://ellislab.com/codeigniter/user-gui...elper.html
Form Validation: http://ellislab.com/codeigniter/user-gui...ation.html
Creating a HTML table from database results: http://ellislab.com/codeigniter/user-gui...table.html
CI General Tutorial: http://ellislab.com/codeigniter/user-gui...index.html

[/quote]

Thanks. I finally found an example: http://ulyssesonline.com/2011/04/21/addi...-projects/

Naturally it didn't work out of the box but the second link you provided (Form Validation) had a lot of info where I could rework the example to make it work. I now have an understanding of the flow (mainly it appears that search "view"is where you setup the link to the "results' view when the user hits submit).

Thanks for the help.




Theme © iAndrew 2016 - Forum software by © MyBB