Jump to content

[SOLVED] how to use form for filtering ??


janim

Recommended Posts

hi every body

i wanna use simple filter like this  :


<form action="" method="post" >
<select name="select2">
      <option value="new">new</option>
      <option value="old">old</option>
    </select>   
</form>
<?
$filter="id desc";
$filter="id asc";
$filter="anything else";

$showing=mysql_db_query($bas,"select * from $movtab  order by $filter ) or die
?>

 

as you see i can't detect what is will change the $filter variable

so any suggestion please

Link to comment
https://forums.phpfreaks.com/topic/75320-solved-how-to-use-form-for-filtering/
Share on other sites

If you want the content that you're filtering to change as you pick new or old then you will need either ajax to change it in a container on the page or just reload the page with the settings that are selected. However, I also would need more details as to what you are trying to do..?

 

If you are planning to reload the page when the form is submitted then you could use $HTTP_POST_VARS or $_GET to grab the settings you select and sort the content. You could also set the default selected item in the select box by echoing the options out and adding (I think this is correct) "selected" inside the <option> tag.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.