Multiple Select List
Hello,
I created a SelectList but how do I store the values with DA in my table?
When I do it like that only the first selection is stored in the table :-(
<?php require_once('database/IchBinMusiker.php'); ?>
<?php require_once("WA_DataAssist/WA_AppBuilder_PHP.php"); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_IchBinMusiker, $IchBinMusiker);
$query_genre = "SELECT * FROM genre ORDER BY genre ASC";
$genre = mysql_query($query_genre, $IchBinMusiker) or die(mysql_error());
$row_genre = mysql_fetch_assoc($genre);
$totalRows_genre = mysql_num_rows($genre);
mysql_select_db($database_IchBinMusiker, $IchBinMusiker);
$query_profil = "SELECT profileid, genre FROM profile WHERE profileid = 5";
$profil = mysql_query($query_profil, $IchBinMusiker) or die(mysql_error());
$row_profil = mysql_fetch_assoc($profil);
$totalRows_profil = mysql_num_rows($profil);?>
<?php
// WA Application Builder Update
if (isset($_POST["button"])) // Trigger
{
$WA_connection = $IchBinMusiker;
$WA_table = "profile";
$WA_redirectURL = "";
$WA_keepQueryString = false;
$WA_indexField = "profileid";
$WA_fieldNamesStr = "genre";
$WA_fieldValuesStr = "".((isset($_POST["liste"]))?$_POST["liste"]:"") ."";
$WA_columnTypesStr = "',none,''";
$WA_comparisonStr = "=";
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
$WA_fieldValues = explode("|", $WA_fieldValuesStr);
$WA_columns = explode("|", $WA_columnTypesStr);
$WA_where_fieldValuesStr = "5";
$WA_where_columnTypesStr = "none,none,NULL";
$WA_where_comparisonStr = "=";
$WA_where_fieldNames = explode("|", $WA_indexField);
$WA_where_fieldValues = explode("|", $WA_where_fieldValuesStr);
$WA_where_columns = explode("|", $WA_where_columnTypesStr);
$WA_where_comparisons = explode("|", $WA_where_comparisonStr);
$WA_connectionDB = $database_IchBinMusiker;
mysql_select_db($WA_connectionDB, $WA_connection);
if (!session_id()) session_start();
$updateParamsObj = WA_AB_generateInsertParams($WA_fieldNames, $WA_columns, $WA_fieldValues, -1);
$WhereObj = WA_AB_generateWhereClause($WA_where_fieldNames, $WA_where_columns, $WA_where_fieldValues, $WA_where_comparisons );
$WA_Sql = "UPDATE `" . $WA_table . "` SET " . $updateParamsObj->WA_setValues . " WHERE " . $WhereObj->sqlWhereClause . "";
$MM_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
if ($WA_redirectURL != "") {
if ($WA_keepQueryString && $WA_redirectURL != "" && isset($_SERVER["QUERY_STRING"]) && $_SERVER["QUERY_STRING"] !== "" && sizeof($_POST) > 0) {
$WA_redirectURL .= ((strpos($WA_redirectURL, '?') === false)?"?":"&").$_SERVER["QUERY_STRING"];
}
header("Location: ".$WA_redirectURL);
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Unbenanntes Dokument</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<p>Liste
<select name="liste" size="<?php echo $totalRows_genre; ?>" multiple="multiple" id="liste">
<?php
do {
?>
<option value="<?php echo $row_genre['genreid']?>"<?php if (!(strcmp($row_genre['genreid'], $row_profil['genre']))) {echo "selected=\"selected\"";} ?>><?php echo $row_genre['genre']?></option>
<?php
} while ($row_genre = mysql_fetch_assoc($genre));
$rows = mysql_num_rows($genre);
if($rows > 0) {
mysql_data_seek($genre, 0);
$row_genre = mysql_fetch_assoc($genre);
}
?>
</select>
</p>
<p>
<input type="submit" name="button" id="button" value="Senden" />
</p>
</form>
</body>
</html>
<?php
mysql_free_result($genre);
mysql_free_result($profil);
?>