chauxvive chauxvive - 1 year ago 84
PHP Question

separating categories with Filemaker api / php

I'm stuck on a massive project I'm helping with- we have a FileMaker database and I've created an online catalogue for it. Originally we just had clothing and it worked perfectly, but now we're adding other collections as well. I'm trying to make just the the "C" (clothing) collection show up below, but it's not working. I'm new to the FileMaker api so help is greatly appreciated.


/*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 = \"");
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();
$records = $result->getRecords();


Answer Source

I typically use fx.php for querying Filemaker but after a quick look at your code you seem to be filtering the results with the following:

if ($category = "C"){

However the single = is an assignment operator, not a comparison operator. You will want to check if $category is equal to C, not set $category to C.

Try using if ($category == "C"){ instead. Note the double ==

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download