displaying message based on category

windows

Guest
hi

i have my products split into categories and the page my urls are like this

<!-- w --><a class="postlink" href="http://www.mysite/products.php?cat=1">www.mysite/products.php?cat=1</a><!-- w -->
<!-- w --><a class="postlink" href="http://www.mysite/products.php?cat=2">www.mysite/products.php?cat=2</a><!-- w -->

i would like to create a category description based on what page its on and i tried doing this but t didnt work

<? if ($cat=1)
echo "descrition for category one";

but it just printed this no matter what page it was on - can anybody suggest something for me - thanks

simon<?php
$categories = array(
1 => 'description for category one',
2 => 'description for category two',
3 => 'description for category three',
4 => 'description for category four',
5 => 'description for category five'
);

if (isset($_GET['cat']) && isset($categories[$_GET['cat']]))
{
echo $categories[$_GET['cat']];
}
?>Originally posted by symoore22
<? if ($cat=1)
echo "descrition for category one";

but it just printed this no matter what page it was on - can anybody suggest something for me - thanks

simon

You're using only one equals sign, therefore it's assigning $cat the value of one, and always returning true. If you want to compare values, use two (or three) equals signs.More info on this man page: operators.comparison
 
Back
Top