Link to home
Start Free TrialLog in
Avatar of Zeek0
Zeek0

asked on

Print contents in new window

I'm trying to redesign a web-based DB search that I've got running on my server.  As of now, the user enters some basic search criteria into an html form, these criteria are posted to a PHP script, and the script queries the DB and gets matching results.  Each resulting record from the DB is dumped into an HTML table, and the results page is a series of tables, each populated with a record from the DB.

What I want to do is change the initial results page to be a list of links, each one corresponding to a match from the DB.  If the user chooses the last name "Smith" to search, the results page would look something like:

Smith, Adam 10/12/1977
Smith, John  2/8/1980
Smith, Jonas 5/17/1966

I can get as far as outputting a list of links corresponding to the matches from the DB, but I don't know what to actually put *in* the links that will allow me to open a new window, dump code into it, and give the user an option to print.  Is this something I can do with pure PHP, or will I need to throw some javascript in there too?

What I was thinking was to create a class which is instantiated by each new result record from the DB.  The constructor would return the html of the link, which could just be echoed to the intial search results page as unordered list elements from within the while loop that gets the DB results.  When the link is clicked, the ideal action would be for another function in the class to be called, which would open a new window, dump the html-table-encoded results into it, and provide a "print me" link.  

Does anyone have any suggestions on how I might pull this off?
ASKER CERTIFIED SOLUTION
Avatar of LinuxNubb
LinuxNubb
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Zeek0
Zeek0

ASKER

So what I'm seeing is that I'll need two scripts, correct?  

The first will do an initial query for, say, the first name, last name, and birthdate.  The results will be displayed on a table of links, each to a second script with a GET variable.  The second script will query the DB again for the entire record(s) and build the print table out of them.

Is it better, performance-wise and efficiency-wise to use two queries, each one returning as little data as is necessary?  Or is that simply the way it has to be done?  In my case, performance is not a major issue because the database records are short and the maximum number of matches to a particular query would only be a couple dozen.  

It makes more sense to query only for the needed data, but to this point I was getting everything at once because I though the interaction between the script and the DB was the performance bottleneck.  Is that incorrect?  That is, does it hurt performance more to a) have the script receiving and parsing unnecessary data from the DB, in the interest of using a single query or b) query the database repeatedly with more restrictive statements that return less data?


SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Zeek0

ASKER

Thanks for the info.  I got everything working and as far as I can tell, the performance is more than adequate.  Thanks for the help.