Jump to content

If isset statements...


aarbrouk

Recommended Posts

Hello,

 

I am having trouble passing multiple values over to a page in order to perform certain filters on products being retrieved from the database. I think the problem is that I am not writing the "if isset" statements out properly..

 

$brandget = $_SESSION ['BrandID'];

$sql="SELECT * FROM product JOIN brand ON product.brandID=brand.BrandID JOIN style ON product.StyleID=style.StyleID WHERE product.ProductStatus = 'Active' AND product.BrandID = '$brandget'";

 

if(isset($_SESSION['FilterColour'])&& isset($_SESSION['Filter']))

{

$filtergetcolour = $_SESSION['FilterColour'];

$filterget = $_SESSION['Filter'];

$sql=$sql." AND product.Colour='$filtergetcolour' AND product.Gender='$filterget'";

}

echo $sql;

$result = mysql_query($sql);

 

So basically if the filtercolour and the filter exists then add the following sql statement to the $sql statement... However it doesnt do this and looks like it isn't picking up this if statement... Have I done the "if isset" correctly, in terms of syntax (e.g. &&)?

 

The link that is run to perform the filter:

<a href="products.php?FilterColour=Red&BrandID=<?php echo $_SESSION['BrandID']?>">Red</a>

 

help would be much appreciated...

Link to comment
https://forums.phpfreaks.com/topic/149966-if-isset-statements/
Share on other sites

Not sure but is this the link you are sending to the filter page?

 

<a href="products.php?FilterColour=Red&BrandID=<?php echo $_SESSION['BrandID']?>">Red</a>

 

If so your FilterColour would be in the $_GET[] as well as your BrandID, but if you are putting your BrandID

into a session you really don't need to send it in the URL, or I would think. This may be why your isset is not

working right... try this

 

 

change

if(isset($_SESSION['FilterColour'])&& isset($_SESSION['Filter']))

 

To this

if(isset($_GET['FilterColour)&& isset($_SESSION['Filter']))

 

Of course you should do the sanity check on any information before sending to query the DB.

Hope this helps in some way

 

Stpehen

 

Link to comment
https://forums.phpfreaks.com/topic/149966-if-isset-statements/#findComment-787597
Share on other sites

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.