asked on
[boxdest] => Array
(
[0] => WD1
[1] => WD10
[2] => WD11
)
<?php
$conn = mysql_connect("localhost","root","");
mysql_select_db("sample",$conn);
$result = mysql_query("SELECT * FROM boxes where department = '{$_GET['dept']}' ORDER BY custref ASC");
?>
<select name="boxdest[]" id="boxdest" size="7" multiple="multiple">
<?php
$i=0;
while($row = mysql_fetch_array($result)) {
?>
<option value="<?php echo $row["custref"];?>"><?php echo $row["custref"];?></option>
<?php
$i++;
}
?>
</select>
<input type="button" id="submit2" name="submit2" value=">" />
<input type="button" id="submit3" name="submit3" value="<" />
<select name="boxdest2[]" id="boxdest2" size="7" multiple="multiple"></select>
<script type="text/javascript">
$('#submit2').click(function () {
var selected = $('#boxdest > option:selected');
$('#boxdest2').append(selected.clone());
selected.hide();
});
$('#submit3').click(function () {
$('#boxdest').append($('#boxdest2 > option').clone());
$('#boxdest2').empty();
});
</script>
if (isset($_POST['boxdest']))
{
if (!empty($_POST['boxdest']))
{
$destroydata = split(',', $_POST['boxdest'][0]);
$result = array();
foreach ($destroydata as $val4)
{
if ( $val4 != "" )
{
$boxdest[] = $val4;
$result[] = $boxdest;
}
}
}
$arr = array ( 0 => "lorem",1 => "ipsum", 2 => "dolor");
$str = implode (", ", $arr);
echo $str; //it will output result - 'lorem, ipsum, dolor'
$str = "lorem, ipsum, dolor";
$arr= explode(", ",$str);
print_r (explode(", ",$arr)); //it will ouput result as - Array ( [0] => lorem[1] => ipsum [2] =>dolor )
ASKER
$arr = array ( 0 => "lorem",1 => "ipsum", 2 => "dolor");
$total = count($arr);
echo $total; //it will output 3
ASKER
$total = count($str);
$total = count($str);
Won't work - $str is now a string - so the result will be $total = 1$data = is_array($__POST['boxdest']) ? $__POST['boxdest'] : array();
// The above guarantees that $data is set AND is an array. If the $_POST['boxdest']
// does not exist it fails over to an empty array
// Now we can simply do this
$str = implode(',', $data);
$total = count($data);
ASKER
ASKER
To award you answer for the count question.When you assign points you can choose more than one answer - you chose the one that best answers your question as "Best Solution" and any others become "Assisted Solutions". You can choose in the wizard how to apportion points.
ASKER
I only joined today after being away from EE for some time.Welcome back - yes they have made quite a few changes.
ASKER
ASKER
$("#submit").prop( "disabled", true);
ASKER
PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.
TRUSTED BY
ASKER