Chemistry Reference
In-Depth Information
<BODY>
<FORM>
<?php
print marvin_sketch();
print "<p><input type=submit value=search>";
print "pubchem.nci_h23";
foreach (get_columns('pubchem', 'nci_h23') as $key => $value) {
print "<BR><input type=checkbox name=${key}>${key}\n";
}
?>
</FORM>
</BODY>
</HTML>
<?php
function get_columns($schema,$table) {
$dbconn = pg_connect("host=localhost dbname=book user=reader");
$sql = "select * from get_fields('${schema}', '${table}') as
(colnam text, typnam text)";
$result = pg_query($dbconn, $sql);
$columns = array();
while ( $row = pg_fetch_array($result) ) {
$colnam = $row['colnam'];
$columns[${colnam}] = $row['typnam'];
}
pg_close($dbconn);
return $columns;
}
?>
This expands on the previous example, adding the get _ columns php
function and the creation of the form and checkboxes showing the col-
umn names in the html body.
It is beyond the scope of this topic to present an entire Web applica-
tion. The purpose of this discussion is to show how creating and using
SQL functions can facilitate the creation of Web applications. The final
example shows how SMILES stored in a database can be formatted for
display using Marvin. The marvin _ view SQL function is defined as:
Create Or Replace Function marvin_view(text, text) Returns Text As
$EOSQL$
Select '
<script LANGUAGE="JavaScript1.1">
msketch_name = "MView";
mview_begin("/marvin", 200, 200);
mview_param("colorScheme", "atomset");
mview_param("mol", "' || $1 || '");
mview_param("AtomSet0.1", "' ||
array_to_string(list_matches($1, $2),',') ||'");
mview_end();
</script>
'::Text;
$EOSQL$ Language SQL;
Search WWH ::




Custom Search