Hello, While developing i am finding a problem for handeling select box array. Below given code is used to fetch the categories from database and this is selectbox array, ================================================== <select name="Catsearch[]" multiple> <? while ($row = mysql_fetch_assoc($Catresult)) { if($_REQUEST['Catsearch'] == $row["catid"]){ $selVal = "selected"; } else { $selVal = ""; } ?> <option value="<?=$row["catid"]?>" <?=$selVal?>><?=$row["CategoryName"]?></option> <? } ?> </select> HTML: ================================================== I pass this array values as comma saperated values. $TotalCat = sizeof($_REQUEST['Catsearch']); for($i = 0; $i < $TotalCat ; $i++){ if($TotalCat == 1){ $appendVar=$_REQUEST['Catsearch'][0]; } else{ $appendVar=$_REQUEST['Catsearch'][$i].",".$appendVar; } } $sqlc .= " And category in (".$appendVar.")"; PHP: When the value is passed it goes with extra comma. I need to remove last comma. Please suggest me how to handel this. at present my query looks like this select category from CatMast where categorystatus = 'A' and category in (1,2,3,) It should be like this select category from CatMast where categorystatus = 'A' and category in (1,2,3) Please suggest me the solution for removing last comma
if($TotalCat == 1){ $appendVar=$_REQUEST['Catsearch'][0]; } else{ $appendVar= implode(', ', $_REQUEST['Catsearch']); } PHP: And take out the loop.
Hello , I am able to store comma saperated categories in table - the values are stored in this way "2,4,6" Now the catch is when i search by this query it works --------------------------------------------- EmpID | EmpName | EmpCategory --------------------------------------------- 1 | Joe | 1,2,4,6 2 | Sue | 5,3 --------------------------------------------- Note: when i search by this query it works fine for emp table This fails when i search by below given query select * from emptable where EmpID = 1 and EmpCategory in (2,4,6) Code (markup): Please suggest to find proper result for above situation