getdb.inc
author viric@vicerveza
Thu, 18 May 2006 23:47:03 +0200
changeset 0 c270c8b5ddea
permissions -rw-r--r--
Initial release. Usable.
viric@0
     1
<?php
viric@0
     2
	include("db-config.inc");
viric@0
     3
viric@0
     4
	function obtenir_butxaques($connection)
viric@0
     5
	{
viric@0
     6
		$resultat = mysql_query("SELECT id,nom FROM butxaques ORDER BY nom ASC", $connection);
viric@0
     7
viric@0
     8
		if (!$resultat)
viric@0
     9
		{
viric@0
    10
?>
viric@0
    11
			<p> <STRONG>ERROR:</STRONG> Error al obtenir
viric@0
    12
				<STRONG>gent</STRONG>! </p>
viric@0
    13
<?php
viric@0
    14
			echo "Error MYSQL:" . mysql_errno().": ".mysql_error()."<BR>";
viric@0
    15
		}
viric@0
    16
viric@0
    17
		while ($fila = mysql_fetch_row($resultat))
viric@0
    18
			$butxaques[$fila[0]] = $fila[1];
viric@0
    19
		return $butxaques;
viric@0
    20
	}
viric@0
    21
viric@0
    22
	// FUNCIONS PER GENERAR CODI HTML
viric@0
    23
viric@0
    24
	function select_butxaques($variable, $default=-1)
viric@0
    25
	{
viric@0
    26
		global $butxaques;
viric@0
    27
viric@0
    28
		echo "<SELECT name=\"$variable\">\n";
viric@0
    29
viric@0
    30
		foreach(array_keys($butxaques) as $i)
viric@0
    31
		{
viric@0
    32
			echo "<OPTION value=\"" .$i . "\"";
viric@0
    33
			if ($default == $i)
viric@0
    34
				echo " selected";
viric@0
    35
			echo ">" . strtohtml($butxaques[$i]) . "\n";
viric@0
    36
		}
viric@0
    37
viric@0
    38
		echo "</SELECT>";
viric@0
    39
	}
viric@0
    40
viric@0
    41
	function strforquotes($cadena)
viric@0
    42
	{
viric@0
    43
		$new= ereg_replace("\"", "&quotes;", $cadena);
viric@0
    44
viric@0
    45
		return $new;
viric@0
    46
	}
viric@0
    47
viric@0
    48
	function strfromquotes($cadena)
viric@0
    49
	{
viric@0
    50
		$new= ereg_replace("&quotes;", "\"", $cadena);
viric@0
    51
viric@0
    52
		return $new;
viric@0
    53
	}
viric@0
    54
viric@0
    55
?>