I am passing an array of data from a select like so:
<div style="margin:10px;">
<select name="selectlist[]" multiple style="min-width: 200px;" id="selectlist">
<option value="userid">User ID</option>
<option value="username">User Name</option>
</select></div>
<div><input type="submit" value="Submit" id="btnYes" onclick="Scriptit()"></div>
<div id="displaypart"></div>
<script>
function Scriptit(){
var selectlist = $('#selectlist').val();
jQuery.ajax({
url: "<?php echo JURI::base();?>Terminator.php",
type: 'POST',
dataType: "html",
data: { selectlist: selectlist},
success : function(result) {
$('#displaypart').empty();
$('#displaypart').append(result);
} ,
error: function(){}});}
</script>
Now on my page Terminator.php how do I check what elements were selected (I.E. in the array) so I know how to build my query string. Something like this (pseudocdoe not php)
$selectlist = implode(',',$_REQUEST['selectlist']);
$sql = "Select";
if $selectlist.contains("userid") then $sql = .$sql & a.userid;
if $selectlist.contains("username") then $sql = .$sql & b.username;
if $selectlist.contains("userid") then $sql .$sql & from useridtable a;
if $selectlist.contains("username") then $sql = .$sql & inner join usernametable b on a.usralra = b.usralra;