getdb.inc
author viric@vicerveza
Thu, 18 May 2006 23:47:03 +0200
changeset 0 c270c8b5ddea
permissions -rw-r--r--
Initial release. Usable.
<?php
	include("db-config.inc");

	function obtenir_butxaques($connection)
	{
		$resultat = mysql_query("SELECT id,nom FROM butxaques ORDER BY nom ASC", $connection);

		if (!$resultat)
		{
?>
			<p> <STRONG>ERROR:</STRONG> Error al obtenir
				<STRONG>gent</STRONG>! </p>
<?php
			echo "Error MYSQL:" . mysql_errno().": ".mysql_error()."<BR>";
		}

		while ($fila = mysql_fetch_row($resultat))
			$butxaques[$fila[0]] = $fila[1];
		return $butxaques;
	}

	// FUNCIONS PER GENERAR CODI HTML

	function select_butxaques($variable, $default=-1)
	{
		global $butxaques;

		echo "<SELECT name=\"$variable\">\n";

		foreach(array_keys($butxaques) as $i)
		{
			echo "<OPTION value=\"" .$i . "\"";
			if ($default == $i)
				echo " selected";
			echo ">" . strtohtml($butxaques[$i]) . "\n";
		}

		echo "</SELECT>";
	}

	function strforquotes($cadena)
	{
		$new= ereg_replace("\"", "&quotes;", $cadena);

		return $new;
	}

	function strfromquotes($cadena)
	{
		$new= ereg_replace("&quotes;", "\"", $cadena);

		return $new;
	}

?>