Handeling Multiple select
Posted: Tue Apr 10, 2007 7:34 am
feyd | Please use
I pass this array values as comma saperated values.
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
It should be like this
Please suggest me the solution for removing last comma
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
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,Code: Select all
<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>Code: Select all
$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.")";at present my query looks like this
Code: Select all
select category from CatMast where categorystatus = 'A' and category in (1,2,3,)Code: Select all
select category from CatMast where categorystatus = 'A' and category in (1,2,3)feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]