Bman900 Posted October 11, 2009 Share Posted October 11, 2009 Here is the code: <?php $category = $_POST['category']; echo "$category"; if($category = "All") { $result = mysql_query("SELECT email, category FROM newsletter ORDER BY id"); } else { $result = mysql_query("SELECT email, category FROM newsletter WHERE category ='$category' ORDER BY id"); } ?> <table width="500" border="2" cellspacing="0" cellpadding="0"> <tr> <th>Email</th> <th>Category</th> </tr> <?php while($row = mysql_fetch_assoc( $result )) { echo "<tr>"; echo "<td>".$row['email']."</td>"; echo "<td>".$row['category']."</td>"; echo "</tr>"; } ?> </tr> </table> For some of reason even when $category is NOT All it still runs that statement rather than the else. Can any one spot any errors that can solve this? Oh and am only echoing category to check if it is passed along correctly which it is. Link to comment https://forums.phpfreaks.com/topic/177308-small-problem-here/ Share on other sites More sharing options...
cags Posted October 11, 2009 Share Posted October 11, 2009 $category is always equal to "All" as you are assigning not comparing. You've missed an equals sign. if($category == "All") { Link to comment https://forums.phpfreaks.com/topic/177308-small-problem-here/#findComment-934870 Share on other sites More sharing options...
Bman900 Posted October 11, 2009 Author Share Posted October 11, 2009 Wow thank you! I can't beleive I missed that! Link to comment https://forums.phpfreaks.com/topic/177308-small-problem-here/#findComment-935032 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.