PHP Classes

File: example.search.php

Recommend this page to a friend!
  Classes of Dave Smith   USDA PHP Nutritional Products Database Wrapper   example.search.php   Download  
File: example.search.php
Role: Example script
Content type: text/plain
Description: Example Usage
Class: USDA PHP Nutritional Products Database Wrapper
Retrieve nutritional data from USDA database
Author: By
Last change:
Date: 8 years ago
Size: 602 bytes
 

Contents

Class file image Download
<?php
/*
search and display foods that match keywords query
USDA Nutritional Database Wrapper ver 0.1
*/
include('ndbwrap.class.php');

$ndb = new ndbwrap();

$query = 'kale';

$search = $ndb->getSearch($query);

echo
'<h4>NDB Food Search for ['.$search->list->q.'] '.'</h4>';

echo
'<h5>Showing '.$search->list->end.' of '.$search->list->total.' items found</h5>';

foreach(
$search->list->item as $item ){
   
    echo
'['.$item->ndbno.'] '.$item->name.'<br>';
   
}

echo
'<hr>';

echo
'database version '.$search->list->sr.'<br>';

echo
$ndb->USDAcitation.'<br>';
?>