v5:userguide:learn_abstraction:key_value_pairs
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| v5:userguide:learn_abstraction:key_value_pairs [2016/03/17 01:23] – [Server Side Code] mnewnham | v5:userguide:learn_abstraction:key_value_pairs [2021/02/21 13:45] (current) – typo, httpheader for json, param names for mysqli example peterdd | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| <- v5: | <- v5: | ||
| + | ~~NOTOC~~ | ||
| ====== Key/Value Pairs ====== | ====== Key/Value Pairs ====== | ||
| + | ===== An Associative Array ===== | ||
| An often-used SQL construction is to read a table for a key/value pair. This can be used in creating Select Boxes, Radio groups etc. ADOdb contains a shortcut command [[v5: | An often-used SQL construction is to read a table for a key/value pair. This can be used in creating Select Boxes, Radio groups etc. ADOdb contains a shortcut command [[v5: | ||
| Line 42: | Line 44: | ||
| * Program adodbExample.php | * Program adodbExample.php | ||
| */ | */ | ||
| - | include | + | include_once |
| /* | /* | ||
| Line 61: | Line 63: | ||
| $db = newAdoConnection(' | $db = newAdoConnection(' | ||
| - | $db-> | + | # |
| + | $db-> | ||
| $sql = " | $sql = " | ||
| FROM us_states | FROM us_states | ||
| ORDER BY state_code"; | ORDER BY state_code"; | ||
| - | $result = $db-> | + | $result = $db-> |
| while ($r = $result-> | while ($r = $result-> | ||
| { | { | ||
| Line 78: | Line 81: | ||
| * Return the data to the calling progam | * Return the data to the calling progam | ||
| */ | */ | ||
| + | if(!$db-> | ||
| + | header(' | ||
| + | } | ||
| print json_encode($rows); | print json_encode($rows); | ||
| </ | </ | ||
| Line 84: | Line 90: | ||
| The method [[v5: | The method [[v5: | ||
| - | {{htmlmetatags> | + | {{htmlmetatags> |
| - | {{htmlmetatags> | + | {{htmlmetatags> |
v5/userguide/learn_abstraction/key_value_pairs.1458174205.txt.gz · Last modified: (external edit)
