Top Experts [
learn more
]
Top 4-10
webko
9743 K
bandmandq
2458 K
Genx
1525 K
4.
tcmeyers
5.
kbata
6.
Martie
7.
Hammerton
8.
rrenfrow
9.
bneeman
10.
plegler
Welcome,
Guest
. Please
login
or
register
.
May 26, 2013, 02:28:01 AM
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Search:
Advanced search
Welcome to the FileMaker Web Masters Exchange. If you have any questions about how to use this forum, please watch the getting started movie at:
http://www.fmwebschool.com/movies/forum1/forum1.html
27467
Posts in
6068
Topics by
1523
Members
Latest Member:
donok
fmwebschool.com
FMStudio
FMStudio Pro
Stuck on CSV
0 Members and 1 Guest are viewing this topic.
« previous
next »
Pages:
[
1
]
Author
Topic: Stuck on CSV (Read 849 times)
Neill
Newbie
Offline
Posts: 7
Stuck on CSV
«
on:
November 05, 2011, 02:28:19 AM »
Hi
I'd be grateful for any help.
I'm trying to export data as CSV. I followed the video and copied my search results page (renamed it blah, blah) and used the server behaviour.
I can get it to export all the records okay. But when I get it to try to export only the records relevant to the page, it's not getting it right. Also, it seems to get 'stuck' - I mean even if I change the recordset request data, it's still showing the same (incorrect) data in the CSV i.e not what I'm searching for. The output fields are correct (and correctly named) but the results from the search are not what I was trying to find. I hope that I've explained that clearly enough - sorry but it's a bit difficult to describe.
Thanks again for any help.
All the best
Neill
Logged
webko
Global Moderator
Hero Member
Offline
Posts: 2051
Kudos: 9743
Applications:
FX.php
(Guru)
BlackBelt
(Expert)
PHP API
(Advanced)
Re: Stuck on CSV
«
Reply #1 on:
November 06, 2011, 06:53:48 PM »
Sounds to me like your search that generated the original recordset page is not being preserved through to the csv generation page - I'd need to see the php code for both pages to be any surer about this...
Cheers
Webko
Logged
tim.webko_at_gmail.com
glasstream2000
Jr. Member
Offline
Posts: 56
Re: Stuck on CSV
«
Reply #2 on:
March 22, 2012, 07:06:52 AM »
I am trying the same thing, mine works, but it is returning all records and not the found set. I have a search field on one webpage, and on the results page, I have the repeating field with a link to export csv. The repeating field lists the correct records in the found set, but the csv exports the entire table.
Also the fields I am exporting like First Name, Last Name, Module etc.. are showing up in the top of the excel sheet saying "
Notice
: Undefined index: LName in
C:\Inetpub\wwwroot\BR\Combined\Hall\csv_ex.php
on line
6
"
Not quite sure what I am doing wrong, I have the correct found set on the webpage, not sure why the csv export is exporting the entire table.
Thanks in advance!
Logged
webko
Global Moderator
Hero Member
Offline
Posts: 2051
Kudos: 9743
Applications:
FX.php
(Guru)
BlackBelt
(Expert)
PHP API
(Advanced)
Re: Stuck on CSV
«
Reply #3 on:
March 22, 2012, 03:09:23 PM »
See my original response... Need to see the code for the link and the csv generation page
Logged
tim.webko_at_gmail.com
glasstream2000
Jr. Member
Offline
Posts: 56
Re: Stuck on CSV
«
Reply #4 on:
April 23, 2012, 12:26:19 PM »
Sorry webko for the very late reply.
This is the code to the result page.
<?php // FMStudio Pro - do not remove comment, needed for DreamWeaver support ?>
<?php require_once('Connections/MariettaDataView.php'); ?>
<?php require_once('Connections/MariettaAdminLogin.php'); ?>
<?php
$Results_find = $MariettaDataView->newFindCommand('UserInfoCombinedFY11');
$Results_findCriterions = array('LName'=>$_GET['LName'],'School'=>$_GET['School'],'FName'=>$_GET['FName'],'Module'=>$_GET['Module'],);
foreach($Results_findCriterions as $key=>$value) {
$Results_find->AddFindCriterion($key,$value);
}
$AdminLogin_find = $MariettaAdminLogin->newFindCommand('Admin');
$AdminLogin_findCriterions = array('Username'=>'=='.fmsEscape($_SESSION["MariettaAdminLogin_tableLogin"]["user"]),'Password'=>'=='.fmsEscape($_SESSION["MariettaAdminLogin_tableLogin"]["pass"]),);
foreach($AdminLogin_findCriterions as $key=>$value) {
$AdminLogin_find->AddFindCriterion($key,$value);
}
fmsSetPage($Results_find,'Results',40);
?>
<?php echo fmsSortLink_Process('Results'); ?>
<?php
fmsSetPage($AdminLogin_find,'AdminLogin',10);
$Results_result = $Results_find->execute();
$AdminLogin_result = $AdminLogin_find->execute();
if(FileMaker::isError($Results_result)) fmsTrapError($Results_result,"AdminError.php");
if(FileMaker::isError($AdminLogin_result)) fmsTrapError($AdminLogin_result,"AdminError.php");
if(FileMaker::isError($AdminLogin_result)) fmsTrapError($AdminLogin_result,"error.php");
fmsSetLastPage($Results_result,'Results',40);
$Results_row = current($Results_result->getRecords());
fmsSetLastPage($AdminLogin_result,'AdminLogin',10);
$Results_row = current($Results_result->getRecords());
$AdminLogin_row = current($AdminLogin_result->getRecords());
// FMStudio v1.02 - do not remove comment, needed for DreamWeaver support ?>
This is the exported csv page:
<?php // FMStudio Pro - do not remove comment, needed for DreamWeaver support ?>
<?php require_once('Connections/MariettaDataView.php'); ?>
<?php
$Results_find = $MariettaDataView->newFindCommand('UserInfoCombinedFY11');
$Results_findCriterions = array('LName'=>$_GET['LName'],'FName'=>$_GET['FName'],'Module'=>$_GET['Module'],'Last4'=>$_GET['Last4'],);
foreach($Results_findCriterions as $key=>$value) {
$Results_find->AddFindCriterion($key,$value);
}
fmsSetPage($Results_find,'Results',);
?>
<?php echo fmsSortLink_Process('Results'); ?>
<?php
$Results_result = $Results_find->execute();
if(FileMaker::isError($Results_result)) fmsTrapError($Results_result,"AdminError.php");
fmsSetLastPage($Results_result,'Results',);
$Results_row = current($Results_result->getRecords());
$FMStudioV2->CSV_Export('Results',array(
array('FName','FName'),
array('LName','LName'),
array('Module','Module'),
array('Last4','Last4'),
),'current','export.csv/;/Yes/;/Download');
$Results_row = current($Results_result->getRecords());
$Results_row = current($Results_result->getRecords());
// FMStudio v1.02 - do not remove comment, needed for DreamWeaver support ?>
After playing with it and recreating the page over and over I now get this error: Parse error: syntax error, unexpected ')' in C:\Inetpub\wwwroot\BR\Combined\Marietta\ex_port.php on line 10
The video looks so easy, it just will not export my found set, just the entire table.
Logged
glasstream2000
Jr. Member
Offline
Posts: 56
Re: Stuck on CSV
«
Reply #5 on:
April 23, 2012, 12:37:22 PM »
Using this on the csv export page works, it downloads the csv file, it just has all the records and not the found set!
<?php // FMStudio Pro - do not remove comment, needed for DreamWeaver support ?>
<?php require_once('Connections/MariettaDataView.php'); ?>
<?php require_once('Connections/MariettaAdminLogin.php'); ?>
<?php
$Results_find = $MariettaDataView->newFindCommand('UserInfoCombinedFY11');
$Results_findCriterions = array('LName'=>$_GET['LName'],'School'=>$_GET['School'],'FName'=>$_GET['FName'],'Module'=>$_GET['Module'],);
foreach($Results_findCriterions as $key=>$value) {
$Results_find->AddFindCriterion($key,$value);
}
$AdminLogin_find = $MariettaAdminLogin->newFindCommand('Admin');
$AdminLogin_findCriterions = array('Username'=>'=='.fmsEscape($_SESSION["MariettaAdminLogin_tableLogin"]["user"]),'Password'=>'=='.fmsEscape($_SESSION["MariettaAdminLogin_tableLogin"]["pass"]),);
foreach($AdminLogin_findCriterions as $key=>$value) {
$AdminLogin_find->AddFindCriterion($key,$value);
}
fmsSetPage($Results_find,'Results',40);
?>
<?php echo fmsSortLink_Process('Results'); ?>
<?php
fmsSetPage($AdminLogin_find,'AdminLogin',10);
$Results_result = $Results_find->execute();
$AdminLogin_result = $AdminLogin_find->execute();
if(FileMaker::isError($Results_result)) fmsTrapError($Results_result,"AdminError.php");
if(FileMaker::isError($AdminLogin_result)) fmsTrapError($AdminLogin_result,"AdminError.php");
if(FileMaker::isError($AdminLogin_result)) fmsTrapError($AdminLogin_result,"error.php");
fmsSetLastPage($Results_result,'Results',40);
$Results_row = current($Results_result->getRecords());
fmsSetLastPage($AdminLogin_result,'AdminLogin',10);
$Results_row = current($Results_result->getRecords());
$AdminLogin_row = current($AdminLogin_result->getRecords());
// FMStudio v1.02 - do not remove comment, needed for DreamWeaver support ?>
Logged
glasstream2000
Jr. Member
Offline
Posts: 56
Re: Stuck on CSV
«
Reply #6 on:
April 25, 2012, 03:57:22 PM »
I am assuming somethings wrong with the code or var, since it is returning the entire table instead of the found set. Thou I might be way off to
Logged
webko
Global Moderator
Hero Member
Offline
Posts: 2051
Kudos: 9743
Applications:
FX.php
(Guru)
BlackBelt
(Expert)
PHP API
(Advanced)
Re: Stuck on CSV
«
Reply #7 on:
April 25, 2012, 04:04:13 PM »
OK, on the export file, try using
Code:
print_r($_GET)
Which should give you all of the parameters being passed to the page to generate the csv
Logged
tim.webko_at_gmail.com
glasstream2000
Jr. Member
Offline
Posts: 56
Re: Stuck on CSV
«
Reply #8 on:
April 27, 2012, 08:07:03 AM »
Sorry webko to have to ask, but where would I insert that? tried a few things and none of them have worked so far.
Thank you so much for your help!
Logged
webko
Global Moderator
Hero Member
Offline
Posts: 2051
Kudos: 9743
Applications:
FX.php
(Guru)
BlackBelt
(Expert)
PHP API
(Advanced)
Re: Stuck on CSV
«
Reply #9 on:
April 29, 2012, 05:37:48 PM »
Somewhere near the top of the page that is creating the csv file... Like:
Code:
<?php
// FMStudio Pro - do not remove comment, needed for DreamWeaver support
?>
<?php
require_once(
'Connections/MariettaDataView.php'
);
?>
<?php
require_once(
'Connections/MariettaAdminLogin.php'
);
?>
<?php
echo
"GET array looks like: "
;
//Something just echoed to screen to check it does something
print_r
(
$_GET
);
//Here would be good
$Results_find
=
$MariettaDataView
->
newFindCommand
(
'UserInfoCombinedFY11'
);
$Results_findCriterions
= array(
'LName'
=>
$_GET
[
'LName'
],
'School'
=>
$_GET
[
'School'
],
'FName'
=>
$_GET
[
'FName'
],
'Module'
=>
$_GET
[
'Module'
],);
foreach(
$Results_findCriterions
as
$key
=>
$value
) {
...
Logged
tim.webko_at_gmail.com
glasstream2000
Jr. Member
Offline
Posts: 56
Re: Stuck on CSV
«
Reply #10 on:
April 29, 2012, 06:05:04 PM »
Thanks for the reply Weko
I entered your code like below, and it exports the csv, along with GET array looks like in the csv export but it is still returning the entire set of records, not the found set that I am trying to print. Is there a command to add to your code to that would pull just the found set, or even take the repeating region and export it maybe? I am going off Michael's video
http://www.youtube.com/watch?v=t_i_GThc7E4
It has to be something easy, but just missing it.
Thanks for your help webko!!
<?php // FMStudio Pro - do not remove comment, needed for DreamWeaver support ?>
<?php require_once('Connections/MariettaDataView.php'); ?>
<?php require_once('Connections/MariettaAdminLogin.php'); ?>
<?php
echo "GET array looks like: "; //Something just echoed to screen to check it does something
print_r($_GET); //Here would be good
$Results_find = $MariettaDataView->newFindCommand('UserInfoCombinedFY11');
$Results_findCriterions = array('LName'=>$_GET['LName'],'School'=>$_GET['School'],'FName'=>$_GET['FName'],'Module'=>$_GET['Module'],);
foreach($Results_findCriterions as $key=>$value) {
$Results_find->AddFindCriterion($key,$value);
}
$AdminLogin_find = $MariettaAdminLogin->newFindCommand('Admin');
$AdminLogin_findCriterions = array('Username'=>'=='.fmsEscape($_SESSION["MariettaAdminLogin_tableLogin"]["user"]),'Password'=>'=='.fmsEscape($_SESSION["MariettaAdminLogin_tableLogin"]["pass"]),);
foreach($AdminLogin_findCriterions as $key=>$value) {
$AdminLogin_find->AddFindCriterion($key,$value);
}
fmsSetPage($Results_find,'Results',4000);
fmsSetPage($AdminLogin_find,'AdminLogin',10);
?>
<?php echo fmsSortLink_Process('Results'); ?>
<?php
$Results_result = $Results_find->execute();
$AdminLogin_result = $AdminLogin_find->execute();
if(FileMaker::isError($Results_result)) fmsTrapError($Results_result,"AdminError.php");
if(FileMaker::isError($AdminLogin_result)) fmsTrapError($AdminLogin_result,"AdminError.php");
fmsSetLastPage($Results_result,'Results',4000);
$FMStudioV2->CSV_Export('Results',array(
array('FName','FName'),
array('LName','LName'),
array('Module','Module'),
array('Last4','Last4'),
array('Time','Time'),
array('School','School'),
array('YearBorn','YearBorn'),
array('Value List:Modules','Value List:Modules'),
array('Value List:School','Value List:School'),
),'current','export.csv/;/Yes/;/Download');
fmsSetLastPage($AdminLogin_result,'AdminLogin',10);
$AdminLogin_row = current($AdminLogin_result->getRecords());
$Results_row = current($Results_result->getRecords());
$Results_row = current($Results_result->getRecords());
// FMStudio v1.02 - do not remove comment, needed for DreamWeaver support ?>
Logged
webko
Global Moderator
Hero Member
Offline
Posts: 2051
Kudos: 9743
Applications:
FX.php
(Guru)
BlackBelt
(Expert)
PHP API
(Advanced)
Re: Stuck on CSV
«
Reply #11 on:
April 29, 2012, 10:43:16 PM »
OK, this is getting dumb - is there somewhere I can see this in action???
And did anything apart from the csv file and the echo'd teect show up?
Logged
tim.webko_at_gmail.com
glasstream2000
Jr. Member
Offline
Posts: 56
Re: Stuck on CSV
«
Reply #12 on:
April 30, 2012, 08:22:44 AM »
Sorry webko for the frustration, I really appreciate your help greatly!
You can see it here and use webko webko
www.compliancedirector.org/Admin/AdminMarietta.php
Logged
webko
Global Moderator
Hero Member
Offline
Posts: 2051
Kudos: 9743
Applications:
FX.php
(Guru)
BlackBelt
(Expert)
PHP API
(Advanced)
Re: Stuck on CSV
«
Reply #13 on:
April 30, 2012, 03:50:22 PM »
Your actual link on list.php reads csv.php - there are no parameters attached to that link, so it will find all records.
This is also why your print_r of the GET aray is empty, and why the parameters on csv.php complain about being 'undefined' - they don't exist...
Link on list.php should read like:
Code:
<a href="csv.php?LName=
<?php
echo
$_GET
[
'LName'
];
?>
&FName=
<?php
echo
$_GET
[
'FName'
];
?>
&School=
<?php
echo
$_GET
[
'School'
];
?>
&Module=
<?php
echo
$_GET
[
'Module'
];
?>
">CSV</a>
Logged
tim.webko_at_gmail.com
glasstream2000
Jr. Member
Offline
Posts: 56
Re: Stuck on CSV
«
Reply #14 on:
May 05, 2012, 05:41:08 PM »
Webko, your a genius!
Thanks you so much for your expertise! and your willingness to help out a noob.
Till next time, take care!
Logged
Pages:
[
1
]
« previous
next »
Jump to:
Please select a destination:
-----------------------------
General Discussion and Announcements
-----------------------------
=> FMWebschools updates and announcements
===> FMWebschool Training Schedule
=> Newsletter and Community Discussion
=> Webinar and FMWebschool Events
=> General Discussion
===> CDML Old School FileMaker Web Publishing
===> FileMaker Mobile 7/8
=> Holiday Special Product Support
-----------------------------
FMTouch
-----------------------------
=> FMTouch - FileMaker Databases on the iPhone and iPod iTouch
===> FMTouch - Multi Language Discussion
=> FMTouch BlackBerry and FileMaker
-----------------------------
FMStudio
-----------------------------
=> FMStudio
===> FMStudio Connection and Installation Problems
=> FMStudio Pro
-----------------------------
FMWebschool Products and Solutions
-----------------------------
=> Dolphin Shopping Cart System
=> BlackBelt CDML Software
-----------------------------
FileMaker Books
-----------------------------
=> FileMaker Book Questions and Suggestions
-----------------------------
PHP Web Publishing Technologies
-----------------------------
=> FileMaker's New PHP API
=> FileMaker PHP, FX.php custom web publishing
===> Ajax Code and Examples
-----------------------------
FileMaker Inc Products and Technologies
-----------------------------
=> FileMaker Server 9
===> FileMaker Server 7 / 8 Advanced
=> Web Viewer
=> Instant Web Publishing
=> FileMaker XML, XSLT
-----------------------------
Other Resources
-----------------------------
=> Search Engine Optimization and Consulting
===> Marketing Book Reviews
=> FileMaker Web Resources
=> Free JavaScript Code Snips
=> Free PHP Code Snips
=> Web Jobs, Web Consulting
Loading...