Jump to content

IF in CASE problem


NorthWind

Recommended Posts

Hello guys
I have a problem and can't seem to find whats wrong with it.

The code is here

[code]
switch ($serial)
                {
                case 'na':
                  $querycms = "SELECT * FROM cmserial";
                  $resultcms= mssql_query($querycms, $link);
                  $num_itemscm = mssql_num_rows($resultcms);
            
                  echo $num_itemscm;

                     if ($num_itemscm=<0)
                  { $serial=0;}
                  else
                  { $serial=$num_itemscm++;}
                  break;  
                
                  case '':
                  $serial = '(not entered)';
                  break;
                }
[/code]

it returns me an empty blank white page.
I closed some parts and at last found out that the problem is in the if section of it.
Any help will be appriciated since I can not find what's wrong with this code since last friday.
When you close the IF and else section it works, when i put it in, it doesnt.
thanks
Link to comment
https://forums.phpfreaks.com/topic/9746-if-in-case-problem/
Share on other sites

[!--quoteo(post=374176:date=May 16 2006, 09:45 AM:name=Crimpage)--][div class=\'quotetop\']QUOTE(Crimpage @ May 16 2006, 09:45 AM) [snapback]374176[/snapback][/div][div class=\'quotemain\'][!--quotec--]
You have...:

if ($num_itemscm=<0)

the number of rows returned are never going to be less than 0, so just use if ($num_itemscm=0)
or
if ($num_itemscm<1)
David.
[/quote]


Thanks you David, works like magic. I'm from australia as well :)
Link to comment
https://forums.phpfreaks.com/topic/9746-if-in-case-problem/#findComment-36135
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.