On 21 Sep 2002 at 12:51, Ashley M. Kirchner wrote:

> 
>     I'm working on converting several static (price) pages on our site
>     into dynamic pages, with the data stored in an MySQL database and
>     PHP to pull the data out, with CSS to build the page and present it.

I don't see how CSS would build anything, I guess it's just 
terminology.

>      At the same time, I would also like to have a 'printer friendly'
>     link on each page that visitors can click on and get the same page
>     re-rendered for easy printing.  What's the best way to get the data
>     converted from one form to another?  Should I be querying the
>     database again to get the same data to reformat?  Should I store the
>     data in sessions and reformat based on the CSS?  I would think
>     having to query twice for the same thing would be a degradation in
>     performance, right?  So what's the best practice?

I have not idea what the best practice is. If your data changes 
infrequently you could build static pages, nothing faster than static 
pages. Few people work on sites where most of these questions mean 
much. A friend worked on a site that he and I had developed and I left 
the firm and he later said the customer was complaining about response 
time .. I suggested he take the query string and cache the response in 
a db file and check that db file for every incoming request rather than 
going to Oracle (yeah, they were using Oracle when mysql would have 
done fine). They opted to just bolster the hardware, end of complaints 
and it was running plain cgi, not even mod_perl. Oh well.

I do something that few people do. I take a request from the *client* 
and I process it. Just data manipulation. Since I'm doing the web I get 
an html template (from Smarty.php.net in this case) and do a merge. I 
like to use a wrapper, as such:

$data contains an array or arrays of whatever which is all the data 
needed for this page (based on the query string in the request). It is 
the body of the page (I've got smarty in my own class, viewer):

$data['content'] = $g->viewer->Merge($data,$template); 

Now, I merge everything with the WRAPPING page:

print  $g->viewer->Merge($data,'index.html'); 

Here is my index.html page ($content is the body of the page):

{include file="inc/header.html"}

{include file="../site_nav.html"}
<table width="80%">
<tr>
<td valign="top" width="25%">

{include file="./left_nav.html"}

</td>
<td  valign="top" width="74%">
{$content}
</td>
</tr>
</table>

{include file="inc/footer.html"}

__END index.html

So if you want to show a printable page just do something like this:

if($print == 1) {
        print  $g->viewer->Merge($data,'print_index.html'); 

where print_index.html would have a different layout, perhaps minimal 
header and footer or none at all. Or you  could do some processing on 
the data or whatever. 


Peter











-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to