multiple select: Selections not highlighted

--bcaec5555258a377f704a3caa82a
Content-Type: text/plain; charset=ISO-8859-1

**
------------------------------
Hi
I implemented multiselect from the result of mysql query. When I print the
$val (in the end of the code below), it correctly shows all the option being
selected in _GET variable but the items are not selected(highlighted) in the
box. I am guessing the problem is with the declaration and usage of variable
'arrTypeTarget' but may be wrong.
Any suggestion?
Thanks
Fahim


<?php
$conn = mysql_connect('localhost', 'root', 'fahim');
$db = mysql_select_db('rugit',$conn);
if (!$db) die("Unable to connect to MySQL: " . mysql_error());

$arrTypeTarget = null; //declare vars
if(isset($_GET["arrTypeTarget"]) && is_string($_GET["arrTypeTarget"]))
{
$arrTypeTarget = $_GET["arrTypeTarget"];
}
?>

<script language="JavaScript">
function autoSubmit()
{
var formObject = document.forms['theForm'];
formObject.submit();
}
</script>
<form name="theForm" method="get" enctype="multipart/form-data">

<?php
$query = strtolower("show tables like \"human%\"");
print("query is $query");
$result = mysql_query($query, $conn);
$nRows = mysql_num_rows($result);
print"nRows is $nRows";
?>
<br></br>
Select the target array type: <br>
<select name="arrTypeTarget[]" size = "5" multiple="multiple" id =
"arrTypeTarget" onChange="autoSubmit();">

<?php
print("result is $result");
while($row = mysql_fetch_array($result))
{
echo ("<option value=\"$row[0]\" " . ($arrTypeTarget == $row["0"] ? "
selected" : "") . ">$row[0]</option>");
}
echo"</select><br>";
$val = implode(", ", $_GET["arrTypeTarget"]);
print("arrTypeTarget is: $val");
?>

</form>


----
Fahim

--bcaec5555258a377f704a3caa82a--
Fahim M [ Sa, 21 Mai 2011 17:11 ] [ ID #2059871 ]
PHP » gmane.comp.php.database » multiple select: Selections not highlighted

Vorheriges Thema: Where to put submit button with multiple _GET or _POST??
Nächstes Thema: string value in select tag not working as desired with strings