cristobal Posted September 16, 2008 Share Posted September 16, 2008 I have been battling with this for two days and can't get it right for some reason. I am new to php if you can tell. I have a form with other fields in it, but one field is a multiple select list box. The form submits to a SQL for input into a mysql dbase. I want to pass all of the selected fields in the listbox (could be one, two , three or twelve) to the field in the dbase. I can't seem to store the values selected into an array. For testing purposes, I print the array out on the confirmation page, but there is nothing in the array or I get just the word array. Here is my code: $propertyfeature=serialize($_POST['propertyfeature[]']); //takes the data from a post operation... { then some more code then the SQL $sql->execute ( "INSERT INTO " . $property_table . " ( id, agentref, propertyoption, propertyref, propertytype, propertyprice, propertybedrooms, propertybathrooms, propertyheating, propertyyearbuilt, propertylivingarea, propertyplotsize, propertyswimmingpool, propertygarage, propertyfurnished, propertyaddress, propertylocation, propertyfeature, shortdescription, longdescription, propertystatus, virtualtour, propertyarea, propertyphoto1, propertyphoto2, propertyphoto3, propertyphoto4, propertyphoto5, propertyphoto6, propertyphoto7, propertyphoto8, propertyphoto9, propertyphoto10, propertyviews, propertyshow, featuredproperty, propertyowner, dateadded ) VALUES ( NULL, " . $sql->quote ( $cgi->getValue ( "agentref" ) ) . ", " . $sql->quote ( $cgi->getValue ( "propertyoption" ) ) . ", " . $sql->quote ( $cgi->getValue ( "propertyref" ) ) . ", " . $sql->quote ( $cgi->getValue ( "propertytype" ) ) . ", " . $sql->quote ( $cgi->getValue ( "propertyprice" ) ) . ", " . $sql->quote ( $cgi->getValue ( "propertybedrooms" ) ) . ", " . $sql->quote ( $cgi->getValue ( "propertybathrooms" ) ) . ", " . $sql->quote ( $cgi->getValue ( "propertyheating" ) ) . ", " . $sql->quote ( $cgi->getValue ( "propertyyearbuilt" ) ) . ", " . $sql->quote ( $cgi->getValue ( "propertylivingarea" ) ) . ", " . $sql->quote ( $cgi->getValue ( "propertyplotsize" ) ) . ", " . $sql->quote ( $cgi->getValue ( "propertyswimmingpool" ) ) . ", " . $sql->quote ( $cgi->getValue ( "propertygarage" ) ) . ", " . $sql->quote ( $cgi->getValue ( "propertyfurnished" ) ) . ", " . $sql->quote ( $cgi->getValue ( "propertyaddress" ) ) . ", " . $sql->quote ( $cgi->getValue ( "propertylocation" ) ) . ", " . $sql->quote ( $cgi->getValue ( "propertyfeature" ) ) . ", " . $sql->quote ( $cgi->getValue ( "shortdescription" ) ) . ", " . $sql->quote ( $cgi->getValue ( "longdescription" ) ) . ", " . $sql->quote ( $cgi->getValue ( "propertystatus" ) ) . ", " . $sql->quote ( $cgi->getValue ( "virtualtour" ) ) . ", " . $sql->quote ( $cgi->getValue ( "propertyarea" ) ) . ", " . $sql->quote ( $propertyphotos [ 0 ] ) . ", " . $sql->quote ( $propertyphotos [ 1 ] ) . ", " . $sql->quote ( $propertyphotos [ 2 ] ) . ", " . $sql->quote ( $propertyphotos [ 3 ] ) . ", " . $sql->quote ( $propertyphotos [ 4 ] ) . ", " . $sql->quote ( $propertyphotos [ 5 ] ) . ", " . $sql->quote ( $propertyphotos [ 6 ] ) . ", " . $sql->quote ( $propertyphotos [ 7 ] ) . ", " . $sql->quote ( $propertyphotos [ 8 ] ) . ", " . $sql->quote ( $propertyphotos [ 9 ] ) . ", 0, " . ( strtolower ( $cgi->getValue ( "propertyshow" ) ) == "yes" ? 1 : 0 ) . ", 0, " . $sql->quote ( $cgi->getValue ( "propertyowner" ) ) . ", '$dateadded' )" ); ?> Then finally the actual select listbox code: <select name="propertyfeature[]" id="propertyfeature[]" size="5" multiple="multiple"> <?PHP $rows = $sql->execute ( "SELECT * FROM " . $propertyfeatures_table . " ORDER BY propertyfeature ASC", SQL_RETURN_ASSOC ); for ( $i = 0; $i < sizeof ( $rows ); ++$i ) { $row = $rows [ $i ]; ?> <option value="<?php echo $cgi->htmlEncode ( $row [ "propertyfeature" ] ); ?>"> <?php echo $cgi->htmlEncode ( $row [ "propertyfeature" ] ); ?> </option> <?php } ?> </select> Can someone please give me some help, I have read the php.net manual, searched forum sites and can't figure this one out. Thanks for your help beforehand. Link to comment https://forums.phpfreaks.com/topic/124413-multiple-list-box-arrays/ Share on other sites More sharing options...
cristobal Posted September 16, 2008 Author Share Posted September 16, 2008 any ideas anyone, i am still stump, sorry i am not that good at this yet but any help would be appreciated. Link to comment https://forums.phpfreaks.com/topic/124413-multiple-list-box-arrays/#findComment-642559 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.