]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/matita/scripts/public_html/common.php
the web interface for the benchmarking system
[helm.git] / helm / matita / scripts / public_html / common.php
diff --git a/helm/matita/scripts/public_html/common.php b/helm/matita/scripts/public_html/common.php
new file mode 100644 (file)
index 0000000..09de758
--- /dev/null
@@ -0,0 +1,31 @@
+<?php
+
+function query($q) {
+  $db = mysql_pconnect("localhost","helm");
+  mysql_select_db("matita");
+  $rc = mysql_query($q,$db);
+  if(!$rc) {
+    die("Query failed: " . mysql_error());
+  }
+  $result = array();
+  while( $row = mysql_fetch_array($rc, MYSQL_ASSOC)){
+    $result[] = $row;
+  }
+  mysql_free_result($rc);
+  mysql_close($db);
+
+  return $result;
+}
+  
+function array_to_combo($l,$a) {
+  echo "<select name=\"$l\">";
+  echo "<option value=\"--\">--</option>";
+  foreach ($a as $k => $v) {
+    foreach( array_keys($v) as $k1 => $i) {
+      echo "<option value=\"{$v[$i]}\">{$v[$i]}</option>";
+    }
+  }
+  echo "</select>";
+}
+
+?>