Jason T. Slack wrote:
Hello,

I am just getting started with Active4D.

I am tring to understand the demo database that Aparajita puts out. But alas, I am not understanding it. I need to learn Fusebox and get a grasp on that.

Does anyone have a simple example that they can provide that will allow me to query a 4D database from a link on a webpage and spit the results out on a web page? Maybe a non fusebox way? Or can you explain how to do it and why fusebox does what it does?
This isn't a fusebox example. It also doesn't use any of the new Active4D features rowsets. It does show how you would determine query criteria from a link, use that to build a query, and return some simple results.

The href of a link would contain a URL, e.g., http://www.mysite.com/pets.a4d?type=dogs
If the link was served from your site it might simply be pets.a4d?type=dogs

So, assuming you have Active4D setup correctly and a file pets.a4d in your web folder a call to above url would result in a value in a 'type' value in the query parameters collection. If you were posting a form you'd want to check th form collection

$pet_type := _query{"type"} `the type of pet we'll list with our query

Using this information you would search for pets

`get pets based on pet type
if (trim($pet_type) # "") `not empty
   query([PETS];[PETS]pet_type = $pet_type)
else
   reduce selection ([PETS];0) `in case previous selection exists
end if

$requested_types = $pet_type + "s" ` e.g. dogs from type dog

`Write out results. No fancy formatting.
`Pet Type, Breed, Name and Age will be listed.
if (records in selection ([PETS]) > 0)
writebr ("There are " + records in selection ([PETS]) + $requested_types + "in our database.")
   for ($i;1;selected record number([PETS]))
      goto selected record ([PETS];$i)
writebr("Type: "+[PETS]pet_type + "Breed: "+[PETS]pet_breed+ "Name: "+[PETS]pet_name+ "Age: "+[PETS]pet_age
   end for
else
   writebr ("Sorry there aren't any $requested_types in our pets database")
end if

Studying the examples is a good place to start. I'd highly recommend reading the manual if you haven't already.

hth,

Brad

ps - search the manual for /4DCGI/. I don't use 4D's built-in web server, but do know that the 4DCGI issue can bite you ...

Thanks,

-jason

_______________________________________________
Active4D-dev mailing list
[email protected]
http://mailman.aparajitaworld.com/mailman/listinfo/active4d-dev
Archives: http://mailman.aparajitaworld.com/archive/active4d-dev/


_______________________________________________
Active4D-dev mailing list
[email protected]
http://mailman.aparajitaworld.com/mailman/listinfo/active4d-dev
Archives: http://mailman.aparajitaworld.com/archive/active4d-dev/

Reply via email to