I need some help:
1- how I make a "if" like this:
if(current board= "programming"/*if posible by name, if not by board id*/)
2- I want to change the rating system of a tread on one or more specific boards.
for example in "example" and "example2" boards put 10 stars and make the stars showed this way:
cont= current board rating;/*will be beetween 10 after change the rating system to 10*/
for(i=0;i<10;i++)
{
if(cont>=0.88)
{ echo' <img src="fullstar.gif">
cont--;
}
else
if(cont>0.64 and cont<0.88)
{ echo' <img src="3/4star.gif">
cont--;
}
else
if(cont>0.36 and cont<=0.64)
{ echo' <img src="1/2star.gif">
cont--;
}
else
if(cont>0.10 and cont<=0.36)
{ echo' <img src="1/4star.gif"';>
cont--;
}
else
echo'<img src"emptystar.gif">
}
how I can add something like this in php and on the site?
of course this code just make sense if the currentrating is kept in a float number, that I believe it is because probably use a table with the rating to calculate the rating
thanks ;D
You really don't need all those ANDs in there.
My idea:
[code type=php]
if ($somevar > .8)
{
/* Do Something */
}
else if ($somevar > .6)
{
/* Do Something */
}
else if ($somevar > .2)
{
/* Do Something */
}
else
{
/* Do Something */
}
You don't need the upper bound checking because you already fell through on the previous statement, so it must not match that (the else keeps it from running if the previous one ran). Likewise, end the last case without an actual check, which makes that the default action.
A switch statement might also be appropriate here, but that is for you to decide.
Elseif, not else if ;)
sorry, I was dealing with VBScript a bit before I wrote that.
Quote from: heavyccasey on August 14, 2007, 11:15:56 PM
Elseif, not else if ;)
"else if" will also work in php ;).
Bye
DIN1031
Quote from: Motoko-chan on August 14, 2007, 09:04:07 PM
You really don't need all those ANDs in there.
My idea:
[code type=php]
if ($somevar > .8)
{
/* Do Something */
}
else if ($somevar > .6)
{
/* Do Something */
}
else if ($somevar > .2)
{
/* Do Something */
}
else
{
/* Do Something */
}
You don't need the upper bound checking because you already fell through on the previous statement, so it must not match that (the else keeps it from running if the previous one ran). Likewise, end the last case without an actual check, which makes that the default action.
A switch statement might also be appropriate here, but that is for you to decide.
It still need a "for" or another circle, nop? it just will execute one time without it.
still need the variable who keeps the rating of the thread, how to change the options for vote a tread to 10 on a specific board and how to make a "if" like this:
if(current board= "programming"/*if posible by name, if not by board id*/)
Full PHP with the loop I think you're looking for something like.
for($i=0; $i<10; $i++)
{
if ($cont >= 0.88)
{
echo '<img src="fullstar.gif" />';
$cont--;
}
else if ($cont > 0.64)
{
echo '<img src="3/4star.gif" />';
$cont--;
}
else if ($cont > 0.36)
{
echo '<img src="1/2star.gif" />';
$cont--;
}
else if ($cont > 0.10)
{
echo '<img src="1/4star.gif" />';
$cont--;
}
else
echo '<img src="emptystar.gif" />';
}
Could you explain a bit more about
Quote from: perro88 on August 15, 2007, 11:23:44 PM
if(current board= "programming"/*if posible by name, if not by board id*/)
I'm not sure what you are getting at there. Thanks
Quote from: rakuli on August 16, 2007, 09:28:49 AM
Full PHP with the loop I think you're looking for something like.
for($i=0; $i<10; $i++)
{
if ($cont >= 0.88)
{
echo '<img src="fullstar.gif" />';
$cont--;
}
else if ($cont > 0.64)
{
echo '<img src="3/4star.gif" />';
$cont--;
}
else if ($cont > 0.36)
{
echo '<img src="1/2star.gif" />';
$cont--;
}
else if ($cont > 0.10)
{
echo '<img src="1/4star.gif" />';
$cont--;
}
else
echo '<img src="emptystar.gif" />';
}
Could you explain a bit more about
Quote from: perro88 on August 15, 2007, 11:23:44 PM
if(current board= "programming"/*if posible by name, if not by board id*/)
I'm not sure what you are getting at there. Thanks
I´ll try the code later thaks.
about the "if", I want it to do something like if I´m in a certain board(1 or more) do something else do something else. So the if could be maded by the board name or board ID. I just need the if, the rest i think i can handle by miself because it´s simply html