Re: [PHP-DB] What's wrong with this IF statement?

2004-04-22 Thread Miles Thompson
Don't cross post -- you'll eventually annoy enough people that they'll stop 
responding!
Here are some suggestions:

Are you closing braces properly? (Assume you must be, otherwise errors 
would be thrown.

Have you echoed your $cat_id so you know if you are getting?

Use the in_array function to simplify your IF statements.

Test one if statement at a time

MT

At 03:02 PM 4/22/2004 -0400, Robert Sossomon wrote:

My IF statement should be picking up on the numbers, and if the number
matches not be displaying out the information, however I look at the
outputted page and the information is still there, what have I got wrong
on the code?

//Show categories first
$get_cats = "select id_num, id_name, description, cat_code from
categories order by id_name";
$get_cats_res = mysql_query($get_cats) or die(mysql_error());
if (mysql_num_rows($get_cats_res) < 1)
{
 $display_block = "Sorry, no categories to browse.";
}
else
{
 while ($cats = mysql_fetch_array($get_cats_res))
 {
  $cat_id = $cats[id_num];
  if ($cat_id != "53" || $cat_id != "54" || $cat_id != "55" || $cat_id
!= "117" || $cat_id != "118" || $cat_id != "74")
  {
  $cat_title = strtoupper(stripslashes($cats[id_name]));
  $cat_desc = stripslashes($cats[description]);
  $display_block .= "$cat_title
$cat_desc\n";
  while ($items = mysql_fetch_array($get_items_res))
   {
$item_id = $items[id];
$item_num = $items[item_num];
$item_desc = stripslashes($items[description]);
if ($item_num != "ABC-R37" || $item_num !=  "ABC-R42" || $item_num
!= "HB-99100" || $item_num != "RO-PUMPS" || $item_num != "ML-HDGALJUG"
|| $item_num != "PFS-CAC21" || $item_num != "PFS-CO2")
{
$item_num = ltrim($item_num);
$item_num = rtrim($item_num);
$display_block .= "$item_num -
$item_desc\n";
}
   }

My assumption is that BOTH IF statements are not working correctly since
the logic is that if they are built the same they would react the same.
HELP!
TIA!
Robert
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DB] What's wrong with this IF statement?

2004-04-22 Thread Robert Sossomon
My IF statement should be picking up on the numbers, and if the number
matches not be displaying out the information, however I look at the
outputted page and the information is still there, what have I got wrong
on the code?


//Show categories first
$get_cats = "select id_num, id_name, description, cat_code from
categories order by id_name";
$get_cats_res = mysql_query($get_cats) or die(mysql_error());

if (mysql_num_rows($get_cats_res) < 1)
{
 $display_block = "Sorry, no categories to browse.";
}
else
{
 while ($cats = mysql_fetch_array($get_cats_res))
 {
  $cat_id = $cats[id_num];
  if ($cat_id != "53" || $cat_id != "54" || $cat_id != "55" || $cat_id
!= "117" || $cat_id != "118" || $cat_id != "74")
  {
  $cat_title = strtoupper(stripslashes($cats[id_name]));
  $cat_desc = stripslashes($cats[description]);
  $display_block .= "$cat_title
$cat_desc\n";
  while ($items = mysql_fetch_array($get_items_res))
   {
$item_id = $items[id];
$item_num = $items[item_num];
$item_desc = stripslashes($items[description]);
if ($item_num != "ABC-R37" || $item_num !=  "ABC-R42" || $item_num
!= "HB-99100" || $item_num != "RO-PUMPS" || $item_num != "ML-HDGALJUG"
|| $item_num != "PFS-CAC21" || $item_num != "PFS-CO2")
{
$item_num = ltrim($item_num);
$item_num = rtrim($item_num);
$display_block .= "$item_num -
$item_desc\n";
} 
   }


My assumption is that BOTH IF statements are not working correctly since
the logic is that if they are built the same they would react the same.
HELP!

TIA!
Robert

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php