/ Published in: PHP

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php /* the first time it should run the external query get data and cache in local sqli then use that data until refreshed */ require('dbconnect.php'); function getWines($selectString, $distinct = FALSE, $id = NULL, $parentRegion = NULL, $childRegion = NULL, $year = NULL, $rating = NULL){ FROM `wines` WHERE 1 '; $sql .= ( $parentRegion ? ' AND `parentRegion` == \'' . mysql_real_escape_string ($parentRegion) . '\'' : '' ); $sql .= ( $childRegion ? ' AND `childRegion` == \'' . mysql_real_escape_string ($childRegion) . '\'' : '' ); return $result; } /* -- This function returns a json encoded string from the given object **/ function parseJSON($data){ $JSON = ''; } return $JSON; } echo parseJSON(getWines('*')); ?>
Comments
