Jump to content

if statement and drop menu


sabo86

Recommended Posts

if($_POST['searchtype']="Accessories")

  $field='Accessories';

  elseif ($_POST['searchtype']="Seatings")

  $field='Seatings';

  elseif ($_POST['searchtype']="Local Office Furniture")

  $field='Local Office Furniture';

    elseif ($_POST['searchtype']="European Office Furniture")

  $field='European Office Furniture';

  elseif ($_POST['searchtype']="School and University Furniture")

  $field='School and University Furniture';

 

$query = "select * FROM items where Category = '$field'";

 

Just wondering why $field is always taking the string 'Accessories'?

knowing that searchtype is the drop menu form..??

Link to comment
https://forums.phpfreaks.com/topic/124131-if-statement-and-drop-menu/
Share on other sites

Two things:

 

One: when posting code, put them in between [*code][*/code] tags.

 

Two: fix your conditionals, you're literally setting the $_POST['searchtype'] variables to those values:

 

if($_POST['searchtype']="Accessories")

 

to

 

if($_POST['searchtype']=="Accessories")

 

instead.

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.