Save to .csv file

20 posts by 4 authors in: Forums > CMS Builder
Last Post: November 30, 2010   (RSS)

Chris: It didn't work. All it did was re-display the exact same search and display it. Looks like it didn't even try to save the output as a csv, so I believe there may be something missing?? Just in case, I have uploaded the two files that generate/display the query.



Thanx........... Ragi
--
northernpenguin
Northern Penguin Technologies

"Any sufficiently advanced technology
is indistinguishable from magic."
........Arthur C. Clarke

Re: [northernpenguin] Save to .csv file

By Chris - June 28, 2010

Hi Ragi,

Here's the line you have which links to the CSV file:

<center><a href="?as_csv=1&<?php echo @$_SERVER['QUERY_STRING'] ?>">Download these results in CSV format</a></center>

QUERY_STRING won't contain all the form data. I noticed that you solved the problem a few lines below though!

Try changing this:

<center><a href="?as_csv=1&<?php echo @$_SERVER['QUERY_STRING'] ?>">Download these results in CSV format</a></center>

<br />

<div class="searchblock">
<table cellpadding="3">
<?php $query="";
foreach($_REQUEST as $key=>$value){
if($key!="orderBy"){
$query.="$key=$value&";
}
}
?>


... to this:

<?php $query="";
foreach($_REQUEST as $key=>$value){
if($key!="orderBy"){
$query.="$key=$value&";
}
}
?>


<center><a href="?<?php echo $query ?>as_csv=1">Download these results in CSV format</a></center>

<br />

<div class="searchblock">
<table cellpadding="3">


Does that help? Please let us know if you have any questions.
All the best,
Chris
Jason: I made a small change to my query to limit the number of records displayed on the page to 15. However, when I select the csv output, the csv file only includes the records currently displayed on the page. I want to see the results of the query in the csv file, not just the 1st page.

How can I fix this?
--
northernpenguin
Northern Penguin Technologies

"Any sufficiently advanced technology
is indistinguishable from magic."
........Arthur C. Clarke

Re: [northernpenguin] Save to .csv file

By Chris - November 26, 2010

Hi Ragi,

I'm guessing you added something like the line in red?

list($dms_home_pageRecords, $dms_home_pageMetaData) = getRecords(array(
'tableName' => 'dms_home_page',
'limit' => 15,
));


// if the user has supplied "as_csv" in query string
if (@$_REQUEST['as_csv']) {


Try this:

$limit = 15;
if (@$_REQUEST['as_csv']) {
$limit = ''; // no limit for 'as_csv' requests!
}

list($dms_home_pageRecords, $dms_home_pageMetaData) = getRecords(array(
'tableName' => 'dms_home_page',
'limit' => $limit,
));


// if the user has supplied "as_csv" in query string
if (@$_REQUEST['as_csv']) {


Does that help? Please let me know if you have any questions.
All the best,
Chris

By northernpenguin - November 29, 2010 - edited: November 29, 2010

Chris: The spreadsheet now contains all records, but the view only prints the top 15 records, no more, no less.

ragi
--
northernpenguin
Northern Penguin Technologies

"Any sufficiently advanced technology
is indistinguishable from magic."
........Arthur C. Clarke

Re: [northernpenguin] Save to .csv file

By Chris - November 29, 2010

Hi Ragi,

Is that not what you wanted? If not, please explain to me exactly how you want things to work.
All the best,
Chris
Chris: I want the view to display the records 15 at a time, but the spreadsheet to include all the records in the query.

Hope this clears things up.

Thanx.......... Ragi
--
northernpenguin
Northern Penguin Technologies

"Any sufficiently advanced technology
is indistinguishable from magic."
........Arthur C. Clarke

Re: [northernpenguin] Save to .csv file

By Chris - November 29, 2010

Hi Ragi,

Oh! Is this what you're looking for?

$perPage = 15;
if (@$_REQUEST['as_csv']) {
$perPage = ''; // no limit for 'as_csv' requests!
}

list($dms_home_pageRecords, $dms_home_pageMetaData) = getRecords(array(
'tableName' => 'dms_home_page',
'perPage' => $perPage,
));


// if the user has supplied "as_csv" in query string
if (@$_REQUEST['as_csv']) {

All the best,
Chris
Great! That's exactly waht I was looking for.



Thanx Chris
--
northernpenguin
Northern Penguin Technologies

"Any sufficiently advanced technology
is indistinguishable from magic."
........Arthur C. Clarke