web/getdb.inc
author viric@llimona
Thu, 18 May 2006 22:59:47 +0200
changeset 0 6371497b4e53
permissions -rw-r--r--
Init from svn. The wxpython is the final one.
viric@0
     1
<?php
viric@0
     2
$mysql_server = "localhost";
viric@0
     3
$mysql_user = "lingvigilouser";
viric@0
     4
$mysql_password = "carrinclo";
viric@0
     5
$mysql_db = "lingvigilo";
viric@0
     6
$frazotablo = "frazoj_ru_ca";
viric@0
     7
viric@0
     8
function konekti()
viric@0
     9
{
viric@0
    10
	global $mysql_server, $mysql_user, $mysql_password, $mysql_db;
viric@0
    11
	$connexio = mysql_connect($mysql_server, $mysql_user, $mysql_password);
viric@0
    12
	mysql_select_db($mysql_db, $connexio);
viric@0
    13
	return $connexio;
viric@0
    14
}
viric@0
    15
viric@0
    16
viric@0
    17
function strtosql($cadena)
viric@0
    18
{
viric@0
    19
	return ereg_replace("\'", "\'", $cadena);
viric@0
    20
}
viric@0
    21
viric@0
    22
viric@0
    23
function preni_frazojn($konekto,$fraztipo=0)
viric@0
    24
{
viric@0
    25
	global $frazotablo;
viric@0
    26
	$resultat = mysql_query(
viric@0
    27
		"SELECT id,vorto,frazo,korekta,klarigo,korektisto FROM " .
viric@0
    28
		$frazotablo . " WHERE korekta=" . $fraztipo . ";",
viric@0
    29
		$konekto);
viric@0
    30
viric@0
    31
	echo mysql_error();
viric@0
    32
viric@0
    33
	while ($fila = mysql_fetch_row($resultat))
viric@0
    34
	{
viric@0
    35
		$frazoj[$fila[0]] = array(
viric@0
    36
				"vorto" => $fila[1],
viric@0
    37
				"frazo" => $fila[2],
viric@0
    38
				"korekta" => $fila[3],
viric@0
    39
				"klarigo" => $fila[4],
viric@0
    40
				"korektisto" => $fila[5]);
viric@0
    41
	}
viric@0
    42
viric@0
    43
	if (!isset($frazoj))
viric@0
    44
		$frazoj=0;
viric@0
    45
viric@0
    46
	return $frazoj;
viric@0
    47
}
viric@0
    48
viric@0
    49
function teksto_korekto($korekteco)
viric@0
    50
{
viric@0
    51
	switch($korekteco)
viric@0
    52
	{
viric@0
    53
	case 0: return "Ne korektita"; break;
viric@0
    54
	case 1: return "Ĝusta"; break;
viric@0
    55
	case 2: return "Malĝusta"; break;
viric@0
    56
	case 3: return "Nekutima"; break;
viric@0
    57
	}
viric@0
    58
}
viric@0
    59
?>