Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

return value wrong

Status
Not open for further replies.

asm1

Technical User
Oct 9, 2003
77
GB
can anyone tell me why i get the return value of $counter
Code:
if ($counter%7)
   $i = "1";
   elseif($counter%6)
   $i = "2";
   else $i = "3";
return $i;

this is the first time $i is used.
 
sorry dont know what i was doing but return value is correct? .... pass.
thanks for the quick reply
 
sorry, this Is what was happening. I wrote a function that returned a value. The vale was based on a simple calculation. The calculation was on a number provided and was a mod calculation. If the remainder was 1 then a number was put into $i or if mod 2 a different value to $i else give a different value to $i. Depending on the value returned by $i anyone of three banners could be displayed. The problem was that when I called the function the value of the number before calculation was returned and in fact it still is. When I then pass this number to another variable in a hidden textbox the number is then the correct modulus number.
 
first of all if i am correct:
if($couter%3) will always return true if $counter%3 is not 0, therefore ur if stmt is wrong...

i think this is what u want?
$rem=$counter%7;
if($rem==ValueHere)

Known is handfull, Unknown is worldfull
 
sorry that was a typo as i actually typed in the programme
Code:
if ($counter%7 ==0){
   $i = "1";
}elseif($counter%5 ==0){
   $i = "2";
}elseif($counter%3 ==0){
   $i = "3";
}else{ $i = "3";}
return $i;
but well spotted!
as i already said thanks for your time but i am now getting the desired result
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top