PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Sat Mar 28, 2020 2:58 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Design questions
PostPosted: Sat Oct 20, 2012 12:48 pm 
Offline
Forum Newbie

Joined: Fri Oct 19, 2012 8:57 pm
Posts: 14
I'm a php amateur. I have a basic understanding of programming and have written really small programs in perl before (two separate scripts and a conf file), done a bunch of shell scripting, etc. I do them to solve admin problems or automate stuff I don't want to mess with any more.

I'm working on an application for internal use that will do selects (only) from a database. (FreeBSD, Apache22 and php5.4). I do not need to insert data, create or alter tables, etc. (In fact the user that will do the selects only has rights to do selects.) The database will contain rows of data representing timestamps, IP addresses, ports, protocols and connection state flags. The users should be able to search by src ip, dst ip, src prot, dest port, proto of flag states or combinations of those and for a single date or date and time or a range of dates or a range of dates and times.

So the queries would be something like this: select * from table where val=a, optional val=b, etc.

As I've been working on this I'm wondering if my design makes sense:
index.php - a page that displays whatever I want the user to see - it also includes a menu with links to an About page and a How To page
variables/variables.php - storage for commonly used globals
includes/search_functions.php - a common container for all the functions required to do the searches
includes/search_form.php - the form that allows the user to select the desired search parameters
includes/view_tables.php - a page that formats the return into a table for the returned data

Right now I'm including view_tables.php into the index page in the content div and it displays the table fine.

What I'm wondering how to do is to use index.php to display first the search form and then the view_tables page based on what action took place. IOW, when you first load the application, the index page would display the search form. When you click on submit, the index page would display the results of the search. Once the search results are returned, obviously there would have to be the ability to return to the form to do a second search etc.

Does this make sense? Or should the results be displayed on a separate page? What are the pros and cons of using the index page versus a separate results page?


Top
 Profile  
 
 Post subject: Re: Design questions
PostPosted: Sat Oct 20, 2012 6:29 pm 
Offline
Spammer :|
User avatar

Joined: Wed Oct 15, 2008 2:35 am
Posts: 6617
Location: WA, USA
For something simple like you've explained, the solution you have is fine. If it were something more complex then I would suggest a more robust architecture but this is the kind of thing an experienced PHP developer would hammer out in a day or two (no offense - it's just a simple project).

* Make sure that the included files are just snippets of HTML and not the whole page with <html> and all. index.php takes care of that
* The search form is really just a form but you probably want it to persist values (aka "sticky forms")
* I would include the "do I display myself" form logic in the form page, that way you include it for every page load. It can define an array of values from the form - that way the actual details of how the form works stay in the one file and index.php doesn't have to look at $_POST
* The results page takes a resultset or an array of results (either's fine) and displays them
* The functions file defines things that index.php will call, and the results would then be given to the results page


Top
 Profile  
 
 Post subject: Re: Design questions
PostPosted: Sat Oct 20, 2012 6:37 pm 
Offline
Forum Newbie

Joined: Fri Oct 19, 2012 8:57 pm
Posts: 14
No offense taken. I know my limitations. Thanks for the analysis.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group