使用 Filemaker 分隔类别 api / php

separating categories with Filemaker api / php

我正在参与一个大型项目 - 我们有一个 FileMaker 数据库,我已经为它创建了一个在线目录。最初我们只有服装并且效果很好,但现在我们也添加了其他系列。我试图让 "C"(服装)系列只显示在下面,但它不起作用。我是 FileMaker api 的新手,非常感谢您的帮助。

  <?php

                /*the function that displays the buttons (the img) of each dress to link to the details page*/
                function displayRecords($records){
                    /*TO DO*/
                    foreach ($records as $record){
                        $photo = $record->getField("Photo");
                        $thumbnail = $record->getField("Thumbnail");
                        $date = $record->getField("Date CR");
                        $tNum = $record->getField("Catalog_Number");
                        $category = $record->getField("Collection");

                         if ($category = "C"){
                            echo ("<div class=\"dimg\">");
                            echo ("<a href = \"http://fadma.edu/historicalcollection/museum/details_test_textiles.php?id=");
                            echo($tNum); 
                            echo ("\">");
                            echo ("<img src= \" ");
                            echo ($thumbnail);
                            echo (" \"></a>");
                            echo ("<div class=\"desc\">");
                            echo ($date);
                            echo ("</div></div>");}
                    }
                }


                $begin = (int)$_GET["begin"];
                $end = (int)$_GET["end"];

                for ($x = $begin; $x <= $end; $x++){
                    $findCommand = $fm->newFindCommand("Listing");
                    $findCommand->addFindCriterion("Photo", "*");
                    $findCommand->addFindCriterion("Date CR", $x);
                    $result = $findCommand->execute();
                    if(FileMaker::isError($result)){
                        continue;
                    }
                    $records = $result->getRecords(); 
                    displayRecords($records);
                }


            ?>

我通常使用 fx.php 来查询 Filemaker,但在快速查看您的代码后,您似乎正在使用以下内容过滤结果:

if ($category = "C"){

然而,单个 = 是赋值运算符,而不是比较运算符。您需要检查 $category 是否等于 C,而不是将 $category 设置为 C

请尝试使用 if ($category == "C"){。注意双 ==