From d895b852a6e160496ffc760d46d3719a3d62ff86 Mon Sep 17 00:00:00 2001 From: Nathan Kinkade Date: Sun, 3 Feb 2008 23:23:24 +0000 Subject: Initial checkin of nutridb.org and basic subversion directory structure --- index.php | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 index.php (limited to 'index.php') diff --git a/index.php b/index.php new file mode 100644 index 0000000..0f78903 --- /dev/null +++ b/index.php @@ -0,0 +1,68 @@ +Select($sql); +# add the "All" category to the beginning of categories +array_unshift($db->_rows, array("fdgrp_cd" => "All", "fdgrp_desc" => "All categories")); +$smarty->assign("foodCats", $db->_rows); + +# if some of the form field were submitted via a GET then load them +# up on the form, else use some defaults +if ( isset($_GET['searchString']) ) { + $smarty->assign("currentSearchString", $_GET['searchString']); +} else { + $smarty->assign("currentSearchString", ""); +} +if ( isset($_GET['searchType']) ) { + $smarty->assign("currentSearchType", $_GET['searchType']); +} else { + $smarty->assign("currentSearchType", "All Words"); +} +if ( isset($_GET['wordType']) ) { + $smarty->assign("currentWordType", $_GET['wordType']); +} else { + $smarty->assign("currentWordType", "Partial Word"); +} +if ( isset($_GET['foodCat']) ) { + $smarty->assign("currentFoodCat", $_GET['foodCat']); +} else { + $smarty->assign("currentFoodCat", "All"); +} +if ( isset($_GET['sortType']) ) { + $smarty->assign("currentSortType", $_GET['sortType']); +} else { + $smarty->assign("currentSortType", "Category"); +} + +# search types, and word types +$smarty->assign("searchTypes", array("All Words", "Any Word", "Exact Phrase")); +$smarty->assign("wordTypes", array("Partial Word", "Full Word")); +$smarty->assign("sortTypes", array("Category", "Food Description", "Popularity")); + + +$sql = " + SELECT nutr_no, nutrdesc FROM nutrientDefs + ORDER BY nutrdesc +"; +$db->Select($sql); +$smarty->assign("nutrientList", $db->_rows); + + +# grab the various parts. these sections are not printed to the screen +# but rather dumped into smarty variables that will simply be printed +# in the template, so the order doesn't matter here at the moment +include("header.php"); +include("sidebar_left.php"); +include("sidebar_right.php"); +include("footer.php"); + +$smarty->display("index.tpl"); + +?> -- cgit v1.2.3