Not a PHP list I know, but there seems to be a lot of talent out there! I'm creating a web based hardware database (Actually it's a bit more than that, but more later!), but I'm having a problem with multi select list boxes. I can fill single select and multi select boxes from the DB and with file names from a folder (for images), I can also show which items were previously selected . Updating/adding to the database is no problem either until I get to the multi select. They all return as empty. e.g. (note, the dN's are all single select or text, the dNAME are multiselect.) ALL multi selects in this example have at least one item selected. foreach($_POST as $name=>$value) { echo $name." - ".$value."<br /> "; } returns...
start print d1 - 6 d2 - 3 d3 - 2 d4 - AC:AC:AC:AC:AC:11 d5 - TEST d6 - 123 d7 - T1ESTT1EST d8 - 0000-00-01 d9 - 0000-00-01 d10 - 8 d11 - 100.10.10.10 d12 - 4 d13 - D17q d14 - 0.5M d15 - picture1.jpg d16 - 3 d17 - 2 d18 - 2 d19 - 1024MB d20 - 1 year dnic - dcdrom - dhdd - dperph - dsoft - d21 - Test Notes Submit - Edit end print<<<< dnic for example allows a number of NIC's to be applied to a machine, as do dcdrom, dperph (peripherals) and dsoft.
It does not matter if the items are pre selected or newly selected the result is the same. register_globals is OFF and I think that track_vars is ON as '--enable-track-vars' is shown in the phpMyAdmin "Configure Command" section. I've looked at masses of examples on the web and can't see what I'm doing wrong, I've been trying ... foreach($_POST['dnic'] as $value){ $tSQL= "INSERT INTO NIClink (stnID,nicID) VALUES ('" . $xID . "','" . $value . "')" ; mysql_query($tSQL); } but of course the array is empty, so my database is filled with 0's! :-( I create my multi-select lists in a table like this <tr > <td width="30%" nowrap class="TableLeft">CD-ROM / DVD</font></td> <td> </font> <select name="dcdrom" size="3" multiple id="dcdrom"> <?php db_createmultiselect("hedra","CDROM","Make, Model, Speed, Serial","cdromID","Make","cdLink","stnID","cdID","Model","Speed","Serial",$I Din) ?> </select><a href="addcdrom.php"><img src="images/hedra_tiny.jpg" alt="Add New" border="0"></a></td> </tr> and ... function db_createmultiselect($linkID,$table1,$sortby,$IDrow,$xmake,$table2,$sID,$lID ,$data1,$data2,$data3,$xIDin) //creates a multi select box //$linkID - database name //$table1 - main table to get data from //$sortby - fields to sort $table1 by //$IDrow - Name of $table1 ID column //$xmake - Name of the MAKE column //$table2 - name of link table //$sID - Column name of Station ID's //$lID - Column name of LINK ID's //$data1-$data3 Name of columns to place in list //$xIDin - Station ID //db_createmultiselect("hedra","NIC","Make, Model, Speed, Serial","NICID","Make","NIClink","stnID","nicID","Model","Speed","Serial",$I Din); { $sqlSQL="SELECT * FROM " . $table1 . " WHERE 1 ORDER BY " . $sortby ; //mysql_connect($DBhost,$uName) or die("Unable to connect to database" . mysql_error()); //@mysql_select_db($dbName) or die("Unable to select database ". $DBName ." " . mysql_error()); //$result = mysql_query($sqlSQL); //if (!$result) { // die('Could not query:' . mysql_error()); //} $result = mysql_db_query($linkID,$sqlSQL); while ($row = mysql_fetch_array($result)) { $ID=$row[$IDrow]; //get maker name $sqlSQL="SELECT * FROM Address WHERE adrID = ". $row[$xmake]; $newRow = mysql_query($sqlSQL); if (!$newRow) { die('Could not query:' . mysql_error()); } //get the data $x1=mysql_result($newRow,0,'Name'); if($data1) $x2=$row[$data1]; if($data2) $x3=$row[$data2]; if($data1){ if($row[$data3]){ $x4="(".$row[$data3].")"; }else{ $s4=""; } } //now find the selected items $sqlSQL="SELECT * FROM " . $table2 . " WHERE " . $sID . " = " . $xIDin . " AND " . $lID . " = " . $row[$IDrow]; $newRow = mysql_db_query($linkID,$sqlSQL); if(mysql_result($newRow,0,$sID)) { $sel="selected"; }else{ $sel=""; } //Okay ready to output! print("