[FX.php List] Record Count after the fact

Andy Gaunt andy at fmpug.com
Fri Feb 16 10:28:44 MST 2007


Jonathan,

What you may want to try is something along the following lines.

Inside your foreach you can create your variables for your php queries (in
this case your if empty statement and then append the row to the new
tempHtml variable.

<?php // Please use long tags, just in case you ever need to do some XML on
the page

$tempHtml =NULL;	//set my variable for collecting the html
foreach($searchResult['data'] as $key => $value) { 
	if(empty($value['flag'][0] ))  { 
	   $price = "${$value['price'][0]}"; 
	}else{ 
	   $price = "Call"; 
	} 
	
$tempHtml .= "
<tr><td>blah</td></tr>
  <tr><td>$price</td></tr><tr><td>blah</td></tr>";
}

echo $tempHtml;

?>


So, what I did here was do the if statement first and create a price
variable. You will also note the use of double quotes instead of singles.
This allows you to place your variables directly in the query (note the
Filemaker variable is wrapped in curly quotes {}.

The tempHtml is appended to each time within the foreach using a period (.)

Then you can echo out your new variable to the page once done.

Andy Gaunt
Office: 321.206.3658
Mobile: 407.810.4722
andy at fmpug.com
http://www.fmpug.com    

2006 FileMaker Excellence Award Winner
Recipient of FileMaker's 2005 "Mad Dog" Public Relations Award

For chapter locations, dates & times please visit the website at
http://www.fmpug.com If you can make it to a meeting, please RSVP at
http://www.fmpug.com/rsvp.php


-----Original Message-----
From: fx.php_list-bounces at mail.iviking.org
[mailto:fx.php_list-bounces at mail.iviking.org] On Behalf Of Jonathan Schwartz
Sent: Friday, February 16, 2007 10:07 AM
To: FX.php Discussion List
Subject: Re: [FX.php List] Record Count after the fact

Thanks very much to Andy Guant who contacted me back channel to 
clarify his suggestion.  Andy was suggesting writing the html out to 
variable in the first loop and then displaying the resulting html 
once the record count was determined.

I think that that is brilliant...except that I am having trouble with 
this age-old problem: combing php and html.  Specifically, dealing 
with an If statement inside the html I am trying to build in the 
variable.  Could use some help.

The following doesn't come close to working.  The essence is how to 
deal with html..php if..html transition.

Also, do I have the right syntax for adding the latest value of 
$temphtml by using $temphtml = .'......

<?
$temphtml ='';	//set my variable for collecting the html
foreach($searchResult['data'] as $key => $value) {
$temphtml = $temphtml.'
<tr><td>blah</td></tr>
  <tr><td>'. if(empty($value['flag'][0] ))  { echo 
"$".$value['price'][0]; }else{ echo "Call"; }
<tr><td>blah</td></tr>'
}
?>


Thanx jonathan

>
>On Feb 15, 2007, at 10:53 AM, Jonathan Schwartz wrote:
>
>>I could do that.  However, that would then add a second for loop: 
>>one to reduce the data set and write the results to an array and 
>>one to write the array for display...in addition to the FMP query. 
>>(Hey guys....do you believe that this kind of talk is coming from 
>>me...former beginner. ;-)   ).
>>
>>Seems that this is particularly resource intensive,  No?
>>
>>Jonathan
>>
>>
>>
>>At 11:25 AM -0500 2/15/07, Andy Gaunt wrote:
>>>Jonathan,
>>>
>>>Rather than do a new page, can you do your for loop outside the HTML
first
>>>(writing everything to a new variable) then echoing this to your page
once
>>>completed?. If so then you could increment a counter variable when the
>>>record matches your criteria ( $counter++; ) and then echo this out
before
>>>you echo out your content from the loop.
>>>
>>>Andy Gaunt
>>>Office: 321.206.3658
>>>Mobile: 407.810.4722
>>>andy at fmpug.com
>>>http://www.fmpug.com
>>
>>--
>>
>>Jonathan Schwartz
>>FileMaker 8 Certified  Developer
>>Associate Member, FileMaker Solutions Alliance
>>Schwartz & Company
>>jonathan at eschwartz.com
>>http://www.eschwartz.com
>>http://www.exit445.com
>>415-381-1852
>>
>>_______________________________________________
>>FX.php_List mailing list
>>FX.php_List at mail.iviking.org
>>http://www.iviking.org/mailman/listinfo/fx.php_list
>
>_______________________________________________
>FX.php_List mailing list
>FX.php_List at mail.iviking.org
>http://www.iviking.org/mailman/listinfo/fx.php_list


-- 

Jonathan Schwartz
FileMaker 8 Certified  Developer
Associate Member, FileMaker Solutions Alliance
Schwartz & Company
jonathan at eschwartz.com
http://www.eschwartz.com
http://www.exit445.com
415-381-1852

_______________________________________________
FX.php_List mailing list
FX.php_List at mail.iviking.org
http://www.iviking.org/mailman/listinfo/fx.php_list



More information about the FX.php_List mailing list