[FX.php List] Which is faster?
Bob Patin
bob at patin.com
Sat Sep 11 13:21:52 MDT 2010
Very cool. I was going to use this:
<input type="checkbox" name="service<?php echo $counter; ?>">
but you're right, I could use the RECID instead, like this:
<input type="checkbox" name="service[<?php echo $recid; ?>]">
I'm not familiar with is_array; I assume that it looks at $_POST['service'], which is an array, and the array will only contain elements that are non-empty, is that right? So the unchecked boxes won't build the array?
Very cool. I'm not as strong with arrays as I'd like to be, didn't know about that command.
Thanks,
Bob
Longterm Solutions
bob at longtermsolutions.com
615-333-6858
http://www.longtermsolutions.com
iChat: bobpatin
FileMaker 9, 10 & 11 Certified Developer
Member of FileMaker Business Alliance and FileMaker TechNet
--
Expert FileMaker Consulting
FileMaker Hosting for all versions of FileMaker
PHP • Full email services • Free DNS hosting • Colocation • Consulting
On Sep 11, 2010, at 2:13 PM, Leo R. Lundgren wrote:
> Pretty much. But using the counter probably isn't necessary. Imagine your checkboxes look like this:
>
> <input type="checkbox" name="service[__SOME_ID__]">
>
> Then on the recieving side I'd do:
>
> $query = new SomeGoodQueryClass();
> $query->setLogicalOr();
> if(isset($_POST['service']) && is_array($_POST['service'])) {
> foreach($_POST['service'] as $someId) {
> $query->addParam('someId', $someId);
> }
> }
> $queryResult = $query->execute();
>
> Now, what you use for __SOME_ID__ above should be a unique value from the records, obviously, usually the primary key of the records (be it your own 'ID' field or the recId from FM).
>
>
> 11 sep 2010 kl. 21.02 skrev Bob Patin:
>
>>
>> On Sep 11, 2010, at 1:48 PM, Leo R. Lundgren wrote:
>>
>>> Isn't it possible to create one query (in page 2) like the equivalent of SQL's "select foo from bar where id=1 or id=3 or id=4"? I.e. building a query that asks for the IDs that were submitted in the form.
>>
>> I haven't tried using the SetLogicalOR() command before; I'll give it a try.
>>
>> So I'll just loop through my form POSTs, pulling recids and adding a line to my query for each returned recid; is that how you'd do it? Something like this:
>>
>> $counter = $_POST['counter']; // this is the # of items that were on the previous form
>>
>> // $_POST['service'] is the recid of the item that was checked
>>
>> $query->SetLogicalOR();
>> while ($i <= $counter){
>> if strlen($_POST['service'])>0){
>> $query->AddDBParam('recid',$_POST['service']);
>> }
>> $i++;
>> }
>> $queryResult = $query->FMFind();
>>
>> That would do it, wouldn't it?
>>
>> BP
>>
>>
>>
>>
>> _______________________________________________
>> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.iviking.org/pipermail/fx.php_list/attachments/20100911/f0fb1f45/attachment.html
More information about the FX.php_List
mailing list