abhiram 0 Report post Posted January 17, 2006 I've been designing an online registration page for my univ. The adminstrative section is going to take care of the registration and they've asked me if I could incorporate a PRINT link on the page which displays the details of the students so that they can take a printout directly of just the table and not the extra links and decorations on the page without having to copy the whole thing into excel or something. Does anyone have any ideas of how to do this? To make myself more clear, here's a screenshot of the admin page: I want a printout of just the table and not of the form or links present at the top. And it should be as easy as clicking a link. Any ideas? Any links will also be appreciated. Thanks. Share this post Link to post Share on other sites
vujsa 0 Report post Posted January 17, 2006 I assume that the form inputs the data into a database. Just write another script to pull the needed files from the database and insert into a printer friendly version of the page.I think that you may want to add a database table for database queries. When you generate the "FULL" feature page, insert the database query used to get the files for the table into it's own table then the link can forward the queries ID number to the printer friendly script. That script runs the sam query but builds a simple version of the table with the results.Kind of like a database session. This could be used as a security log of who is searching and viewing what. You'd have too find a way to clean out the database though. Otherwise it would get real big real fast.It is hard to say exactly what you need to do because I don't have all of the needed information.vujsa Share this post Link to post Share on other sites
abhiram 0 Report post Posted January 17, 2006 Hey ... that's a grand idea. I didn't even think of the need to log all the database queries. I guess it'll be required in the event of any abuse right? I'll look into it. But, maybe, instead of a database query log, isn't a database of people logging in sufficient? I mean, just note down who is logging in at what time?A printer friendly page sounds great. I wonder why I didn't think about that. I think I can create a link to output the same details as the person is viewing to a new window which can then be printed. Thanks a lot Vujsa .Btw, the form on the top is for filtering out the results. There is an edit button on the side which will enable the administrative section to edit the details of any student. Share this post Link to post Share on other sites
vujsa 0 Report post Posted January 18, 2006 What I was thinking was an on event database item delete.Imagine this is you database query for mySQL: $sql = "SELECT id, name, birthday FROM table_name ORDER BY id"; Then you can insert that information into the new table with a few extras:// Insert a Database Query Into the Log$query_string = $sql;$query_time = time();$query_id = md5($query_string.$query_time);$table_name = "DB_queries";$sql = "INSERT INTO $table_name (id, query, time) VALUES ('$query_id','$query_string','$query_time',)";$result = mysql_query($sql, $connection);// Clean Out Old Log Entries$entry_expire = 300; // Number of seconds to keep a log entry 5 minutes shown here.$expire_time = $query_time - $entry_expire;$sql = "DELETE FROM $table_name WHERE time <= $expire_time";$result = mysql_query($sql, $connection); Then just create a link wto you printer friendly script:echo "<a href=\"printer_friendly.php?".$query_id."\">Printer Friendly</a>"; Then just kind of take it from there. You should be able to use the stored DB query to pull the same information from the database for a text only version of the page. You wouldn't need to have a cron job to clean out the database since the database is checked for old log entries every time the original table is generated. The down side to this is that you would add 4 database queries just to display a printer friendly page. It will add to the servers burden. You can cut one query out by storing the $result of the query instead of the actual query string. Since you would already have the array of information stored in the database, the need to perform the query over is not required.This is only good if you plan to keep the "log" free of older data. If this isn't to be used as a security log as well and the log is cleaned out after 5 or 10 minutes it would be ok. The reason is becuase of how large the $result array could be if say 100 student files were selected. So it is a toss up between number of queries and the size of the database table.That was just what I would do if I were you as I understood your question.[/hr]Does the form above work with javascript and simply hide the table rows which don't match or is this serversided and the database is queried each time? I could probably come up with additional methods if I had a better understanding of what your existing script is doing.Happy Coding. vujsa Share this post Link to post Share on other sites
abhiram 0 Report post Posted January 20, 2006 Sorry I didn't reply sooner. I was a bit busy with my projects and stuff.That's a pretty neat idea. The form on the top queries the database each time. So, in effect, I think I just need to include a link on the top or bottom of the page which will pass the same query to another page without the form on the top. All that the form does is select who or what results you want to see. You can select entries according to the hostel, room no., preferred caterer and so on. And whenever you submit the form, the server queries the results and displays them according to the paging constraint, that is, number of rows to be shown in each page. Each time the page is refreshed or anything, the required rows are queried again. I'll have to work on this over the weekend, it's due to be in proper working condition by monday. I'd post the code, but it's in too much of a mess because of the search form on the top. I'll use your code and see how it works out. I just need to maintain a log of all the people who are logging into the admin page and what changes are they making. In fact, maybe I don't even need to store the queries that are being viewed ... maybe only queries which result in a change of a student's profile will be needed. Thanks a lot Vujsa . Btw, how much of a load do 4 extra queries add to the server? Since the admin page will be used by at most a 2-3 people at a time, it shouldn't be too much. The students page will need to allow around 4000 students to register, so I think I better not log their activities. Share this post Link to post Share on other sites
vujsa 0 Report post Posted January 20, 2006 You know, if your form at the top is already doing all of that work, then you can just add one extra step. You currently have 2 buttons "Show" and "Reset". I thin you could add a third button for "Printable"It would be nearly the same as the "Show" buttuon but should trigger an additional function to only display the table. You can add a JavaScript event to the button to actually run the script in a new pop-up window. To create your original page, you probably have a chunk of static HTML ith maybe a variable holding the dynamic HTML that shows as a table. If your table HTML was saved in the variable $table, then you could just used that variable in the printer friendly display and just use plain HTML before and after it. Then you could break your output for either page into 3 sections: Header, Body, Footer.The Body (table) could be built the same for both pages. It is just a table after all.The Header and Footer would differ between the 2 pages. The printer friendly page would use a plain Header and Footer while the original page would use the current Header and Footer. The Header and Footer would be selected based on which button was pressed.Then just add a couple of if statements to determine which button was used.This wouldn't actually add to much to the existing script.Hope This Helps,vujsa Share this post Link to post Share on other sites
abhiram 0 Report post Posted January 21, 2006 I think a print button will be cool. But, instead of trying to divide the entire code into 3 sections, maybe it'll be easier to just write another 'print.php' and copy the stuff that makes the table into it and pass the variables that are required to print it. That way, I won't have to bother about readjusting the code in the main page and can have it print whatever I want in anyway I want. This will give me more flexibility in changing the final look of the print page.This way I've got the print page working out ok. But have to start working on the logging script.Here are links to the main script and the print page. The main page is just the part of the script which displays the form and the table. I've seperated the entire app into different parts as 'adminmain.php', 'adminprofile.php' and so on. 'admin.php' is the main file into which the other files are 'included'. Be warned that I've made a complete mess of the variables and I've used both global variables and non-global variables also. Right now, I'm not emphasising on 'clean' code.... if it works, that'll do. This is the first time I'm making an app this big all on my own. Share this post Link to post Share on other sites