How to bring array value in Select tag PHP

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bahrudeen
Forum Newbie
Posts: 2
Joined: Tue Aug 01, 2006 5:20 am

How to bring array value in Select tag PHP

Post by bahrudeen »

Pimptastic | 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]


Hi,

i have one array called $Arr_Sal_Unit, i want to show this in Select Tag,

Code: Select all

<?
$Currency_List = "";
for($incr=0;$incr<count($Arr_Sal_Unit);$incr++){
if ($post_j_sal_unit == $incr){
$Currency_List = $Currency_List."<option value=""".$incr.""" Selected>".$Arr_Sal_Unit($incr)."</option>";
}
else{
$Currency_List = $Currency_List."<option value=""".$incr.""" Selected>".$Arr_Sal_Unit($incr)."</option>"
}
}
?>

i just mention $Currency_List in the HTML part like

<html >
< tr>
<td>Salary</td>
<td><select name="j_sal_unit">
<? echo $Currenty_List; ?>
</select> <input type="text" name="j_sal" value="<?php echo $post_j_sal; ?>"></td>
</tr>
</html>
i am getting error like :

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in d:\root\Site\multiple\multiple_entry.php on line 26

I want to check the syntax

Code: Select all

$Currency_List = $Currency_List."<option value=""".$incr.""" Selected>".$Arr_Sal_Unit($incr)."</option>";
is it right ?

thanx n advance

Regards
Bahru


Pimptastic | 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]
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

Code: Select all

$Currency_List = $Currency_List.'<option value="'.$incr.'" Selected>'.$Arr_Sal_Unit($incr).'</option>";
and what is $Arr_Sal_Unit($incr)

That isn't correct AT ALL
User avatar
mojeIme
Forum Newbie
Posts: 22
Joined: Sat Jul 29, 2006 8:58 am

Post by mojeIme »

Maybe you could try:

Code: Select all

$Currency_List = $Currency_List.'<option value="'.$incr.'" Selected>'.$Arr_Sal_Unit[$incr].'</option>";
bahrudeen
Forum Newbie
Posts: 2
Joined: Tue Aug 01, 2006 5:20 am

Thanq 4 both

Post by bahrudeen »

Thanx for the solution...
Post Reply