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>
================================================== ========================================
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.")";
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


LinkBack URL
About LinkBacks





Reply With Quote
Bookmarks