]> matita.cs.unibo.it Git - helm.git/blob - helm/software/matita/scripts/public_html/common.php
moved to the new table
[helm.git] / helm / software / matita / scripts / public_html / common.php
1 <?php
2
3 function array_to_combo($a) {
4   foreach($a as $k => $v){
5     echo "<option value=\"{$v}\">{$v}</option>";
6   }
7 }
8
9 function query($q,$f) {
10   $db = mysql_pconnect("localhost","helm");
11   mysql_select_db("matita");
12   $rc = mysql_query($q,$db);
13   if(!$rc) {
14     die("Query failed: " . mysql_error());
15   }
16   while( $row = mysql_fetch_array($rc, MYSQL_ASSOC)){
17     $f($row);
18   }
19   mysql_free_result($rc);
20   mysql_close($db);
21 }
22
23 function time_2_cents($t) {
24   $matches = array();
25   $rex = "/^(\d+)m(\d\d?)\.(\d{2})s$/";
26   $m = preg_match($rex,$t,$matches);
27   if ( $m == 0 ) exit(1);
28   $t_minutes = $matches[1];
29   $t_secs = $matches[2];
30   $t_cents = $matches[3];
31   return ((int) $t_cents) + ((int) $t_secs) * 100 + ((int)$t_minutes) * 6000 ;
32 }
33
34 ?>