need help on a basic php code

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
Deka87
Forum Newbie
Posts: 2
Joined: Sun Jun 21, 2009 11:00 am

need help on a basic php code

Post by Deka87 »

hi, i need to instert a piece of code in my php script but i dont know php so please help me out with it.
i only need a dropdown list with 2 items: the 1st is "show all" and the 2nd is "show active only". then i want the result to be assigned to $filter = (value) like if it's "show all" then it looks like $filter = 1; and if it's "show active only" it looks like $filter = 0;

thanks in advance!
kuttus
Forum Newbie
Posts: 15
Joined: Sun Jun 21, 2009 3:48 am

Re: need help on a basic php code

Post by kuttus »

Deka87 wrote:hi, i need to instert a piece of code in my php script but i dont know php so please help me out with it.
i only need a dropdown list with 2 items: the 1st is "show all" and the 2nd is "show active only". then i want the result to be assigned to $filter = (value) like if it's "show all" then it looks like $filter = 1; and if it's "show active only" it looks like $filter = 0;

thanks in advance!

ru interested to learn php. if u need the solution u can go through the site w3schools where type the dropdown list in search it will show the example for ur issue ok
Deka87
Forum Newbie
Posts: 2
Joined: Sun Jun 21, 2009 11:00 am

Re: need help on a basic php code

Post by Deka87 »

yeah i know but you'd not learn chinese to translate a single sentese. anybody can help with the dropdown still?
Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

Re: need help on a basic php code

Post by Eric! »

Here's your one word translation, now you make fit the context of your needs.

Code: Select all

<?php 
//Setup data
$name1="show all";
$value1=1;
$name2="search all";
$value=2; 
?> 
 
<!- HTML form opening tags --> 
<form action="action" method="post"> 
<select name="option"> 
 
<?php 
echo "<option value=\"$value1\">$name1</option>\n"; 
echo "<option value=\"$value2\">$name2</option>\n"; 
?> 
 
<!- HTML form closing tags --> 
</select> 
<input type="submit"> 
</form>
Post Reply