Laravel floating if greater 85 not working. It show always smaller than 85
I am learning about backend and Laravel recently.
I am stuck on if function() that using floating type on my project.
<td>
$participant->vt_avg,
@if($participant->vt_avg > 85)
x
@else
y
@endif
</td>
It should print vt_avg score, it's "x" if greater than 85 and "y" if smaller than 85.
But it turns out vt_avg,y
the result shows that all vt_avg is smaller than 85
Can you please help me? I am stuck with this code.
php laravel if-statement laravel-5 condition
add a comment |
I am learning about backend and Laravel recently.
I am stuck on if function() that using floating type on my project.
<td>
$participant->vt_avg,
@if($participant->vt_avg > 85)
x
@else
y
@endif
</td>
It should print vt_avg score, it's "x" if greater than 85 and "y" if smaller than 85.
But it turns out vt_avg,y
the result shows that all vt_avg is smaller than 85
Can you please help me? I am stuck with this code.
php laravel if-statement laravel-5 condition
"Number y" is a string its not an integer ?
– Anar Bayramov
Nov 13 '18 at 5:55
so, i want to print string x if it vt_avg greater than 85 and string y if it smaller than 85
– Michael Ritung
Nov 13 '18 at 6:00
can you share your database too I thought its database records
– Anar Bayramov
Nov 13 '18 at 6:01
1
Also, is it 8.5 or 85?
– hktang
Nov 13 '18 at 6:13
1
There's no visible example ofvt_avg
being greater than 85. Everything in your example is smaller than 11
– apokryfos
Nov 13 '18 at 6:37
add a comment |
I am learning about backend and Laravel recently.
I am stuck on if function() that using floating type on my project.
<td>
$participant->vt_avg,
@if($participant->vt_avg > 85)
x
@else
y
@endif
</td>
It should print vt_avg score, it's "x" if greater than 85 and "y" if smaller than 85.
But it turns out vt_avg,y
the result shows that all vt_avg is smaller than 85
Can you please help me? I am stuck with this code.
php laravel if-statement laravel-5 condition
I am learning about backend and Laravel recently.
I am stuck on if function() that using floating type on my project.
<td>
$participant->vt_avg,
@if($participant->vt_avg > 85)
x
@else
y
@endif
</td>
It should print vt_avg score, it's "x" if greater than 85 and "y" if smaller than 85.
But it turns out vt_avg,y
the result shows that all vt_avg is smaller than 85
Can you please help me? I am stuck with this code.
php laravel if-statement laravel-5 condition
php laravel if-statement laravel-5 condition
edited Nov 13 '18 at 9:10
Sayed Mohd Ali
7681317
7681317
asked Nov 13 '18 at 5:43
Michael RitungMichael Ritung
126
126
"Number y" is a string its not an integer ?
– Anar Bayramov
Nov 13 '18 at 5:55
so, i want to print string x if it vt_avg greater than 85 and string y if it smaller than 85
– Michael Ritung
Nov 13 '18 at 6:00
can you share your database too I thought its database records
– Anar Bayramov
Nov 13 '18 at 6:01
1
Also, is it 8.5 or 85?
– hktang
Nov 13 '18 at 6:13
1
There's no visible example ofvt_avg
being greater than 85. Everything in your example is smaller than 11
– apokryfos
Nov 13 '18 at 6:37
add a comment |
"Number y" is a string its not an integer ?
– Anar Bayramov
Nov 13 '18 at 5:55
so, i want to print string x if it vt_avg greater than 85 and string y if it smaller than 85
– Michael Ritung
Nov 13 '18 at 6:00
can you share your database too I thought its database records
– Anar Bayramov
Nov 13 '18 at 6:01
1
Also, is it 8.5 or 85?
– hktang
Nov 13 '18 at 6:13
1
There's no visible example ofvt_avg
being greater than 85. Everything in your example is smaller than 11
– apokryfos
Nov 13 '18 at 6:37
"Number y" is a string its not an integer ?
– Anar Bayramov
Nov 13 '18 at 5:55
"Number y" is a string its not an integer ?
– Anar Bayramov
Nov 13 '18 at 5:55
so, i want to print string x if it vt_avg greater than 85 and string y if it smaller than 85
– Michael Ritung
Nov 13 '18 at 6:00
so, i want to print string x if it vt_avg greater than 85 and string y if it smaller than 85
– Michael Ritung
Nov 13 '18 at 6:00
can you share your database too I thought its database records
– Anar Bayramov
Nov 13 '18 at 6:01
can you share your database too I thought its database records
– Anar Bayramov
Nov 13 '18 at 6:01
1
1
Also, is it 8.5 or 85?
– hktang
Nov 13 '18 at 6:13
Also, is it 8.5 or 85?
– hktang
Nov 13 '18 at 6:13
1
1
There's no visible example of
vt_avg
being greater than 85. Everything in your example is smaller than 11– apokryfos
Nov 13 '18 at 6:37
There's no visible example of
vt_avg
being greater than 85. Everything in your example is smaller than 11– apokryfos
Nov 13 '18 at 6:37
add a comment |
3 Answers
3
active
oldest
votes
you should try this:
<td>
$participant->vt_avg,
@if($participant->vt_avg > 8.5)
x
@else
y
@endif
</td>
it should 8.5. Thank you.
– Michael Ritung
Nov 13 '18 at 6:52
add a comment |
change
@if($participant->vt_avg > 85)
to
@if(floatval($participant->vt_avg > 85))
Read about floatval
add a comment |
How about using floatval() to get the value from string:
(Assuming you want to compare the average with 8.5, not 85)
<td>
$participant->vt_avg,
@if(floatal($participant->vt_avg) > 8.5)
x
@else
y
@endif
</td>
See: http://php.net/manual/en/function.floatval.php
i have try it but didnt work. the result is just the same even without using floatval(). because vt_avg is already float
– Michael Ritung
Nov 13 '18 at 6:17
1
I see. Do you want to campare the number with85
or8.5
? It seems your vt_avg is less than 10. @MichaelRitung
– hktang
Nov 13 '18 at 6:20
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53274543%2flaravel-floating-if-greater-85-not-working-it-show-always-smaller-than-85%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
you should try this:
<td>
$participant->vt_avg,
@if($participant->vt_avg > 8.5)
x
@else
y
@endif
</td>
it should 8.5. Thank you.
– Michael Ritung
Nov 13 '18 at 6:52
add a comment |
you should try this:
<td>
$participant->vt_avg,
@if($participant->vt_avg > 8.5)
x
@else
y
@endif
</td>
it should 8.5. Thank you.
– Michael Ritung
Nov 13 '18 at 6:52
add a comment |
you should try this:
<td>
$participant->vt_avg,
@if($participant->vt_avg > 8.5)
x
@else
y
@endif
</td>
you should try this:
<td>
$participant->vt_avg,
@if($participant->vt_avg > 8.5)
x
@else
y
@endif
</td>
answered Nov 13 '18 at 6:29
Saurabh DhariwalSaurabh Dhariwal
1,190113
1,190113
it should 8.5. Thank you.
– Michael Ritung
Nov 13 '18 at 6:52
add a comment |
it should 8.5. Thank you.
– Michael Ritung
Nov 13 '18 at 6:52
it should 8.5. Thank you.
– Michael Ritung
Nov 13 '18 at 6:52
it should 8.5. Thank you.
– Michael Ritung
Nov 13 '18 at 6:52
add a comment |
change
@if($participant->vt_avg > 85)
to
@if(floatval($participant->vt_avg > 85))
Read about floatval
add a comment |
change
@if($participant->vt_avg > 85)
to
@if(floatval($participant->vt_avg > 85))
Read about floatval
add a comment |
change
@if($participant->vt_avg > 85)
to
@if(floatval($participant->vt_avg > 85))
Read about floatval
change
@if($participant->vt_avg > 85)
to
@if(floatval($participant->vt_avg > 85))
Read about floatval
answered Nov 13 '18 at 6:32
Danyal SandeeloDanyal Sandeelo
8,20622141
8,20622141
add a comment |
add a comment |
How about using floatval() to get the value from string:
(Assuming you want to compare the average with 8.5, not 85)
<td>
$participant->vt_avg,
@if(floatal($participant->vt_avg) > 8.5)
x
@else
y
@endif
</td>
See: http://php.net/manual/en/function.floatval.php
i have try it but didnt work. the result is just the same even without using floatval(). because vt_avg is already float
– Michael Ritung
Nov 13 '18 at 6:17
1
I see. Do you want to campare the number with85
or8.5
? It seems your vt_avg is less than 10. @MichaelRitung
– hktang
Nov 13 '18 at 6:20
add a comment |
How about using floatval() to get the value from string:
(Assuming you want to compare the average with 8.5, not 85)
<td>
$participant->vt_avg,
@if(floatal($participant->vt_avg) > 8.5)
x
@else
y
@endif
</td>
See: http://php.net/manual/en/function.floatval.php
i have try it but didnt work. the result is just the same even without using floatval(). because vt_avg is already float
– Michael Ritung
Nov 13 '18 at 6:17
1
I see. Do you want to campare the number with85
or8.5
? It seems your vt_avg is less than 10. @MichaelRitung
– hktang
Nov 13 '18 at 6:20
add a comment |
How about using floatval() to get the value from string:
(Assuming you want to compare the average with 8.5, not 85)
<td>
$participant->vt_avg,
@if(floatal($participant->vt_avg) > 8.5)
x
@else
y
@endif
</td>
See: http://php.net/manual/en/function.floatval.php
How about using floatval() to get the value from string:
(Assuming you want to compare the average with 8.5, not 85)
<td>
$participant->vt_avg,
@if(floatal($participant->vt_avg) > 8.5)
x
@else
y
@endif
</td>
See: http://php.net/manual/en/function.floatval.php
edited Nov 13 '18 at 6:36
answered Nov 13 '18 at 6:11
hktanghktang
9391329
9391329
i have try it but didnt work. the result is just the same even without using floatval(). because vt_avg is already float
– Michael Ritung
Nov 13 '18 at 6:17
1
I see. Do you want to campare the number with85
or8.5
? It seems your vt_avg is less than 10. @MichaelRitung
– hktang
Nov 13 '18 at 6:20
add a comment |
i have try it but didnt work. the result is just the same even without using floatval(). because vt_avg is already float
– Michael Ritung
Nov 13 '18 at 6:17
1
I see. Do you want to campare the number with85
or8.5
? It seems your vt_avg is less than 10. @MichaelRitung
– hktang
Nov 13 '18 at 6:20
i have try it but didnt work. the result is just the same even without using floatval(). because vt_avg is already float
– Michael Ritung
Nov 13 '18 at 6:17
i have try it but didnt work. the result is just the same even without using floatval(). because vt_avg is already float
– Michael Ritung
Nov 13 '18 at 6:17
1
1
I see. Do you want to campare the number with
85
or 8.5
? It seems your vt_avg is less than 10. @MichaelRitung– hktang
Nov 13 '18 at 6:20
I see. Do you want to campare the number with
85
or 8.5
? It seems your vt_avg is less than 10. @MichaelRitung– hktang
Nov 13 '18 at 6:20
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53274543%2flaravel-floating-if-greater-85-not-working-it-show-always-smaller-than-85%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
"Number y" is a string its not an integer ?
– Anar Bayramov
Nov 13 '18 at 5:55
so, i want to print string x if it vt_avg greater than 85 and string y if it smaller than 85
– Michael Ritung
Nov 13 '18 at 6:00
can you share your database too I thought its database records
– Anar Bayramov
Nov 13 '18 at 6:01
1
Also, is it 8.5 or 85?
– hktang
Nov 13 '18 at 6:13
1
There's no visible example of
vt_avg
being greater than 85. Everything in your example is smaller than 11– apokryfos
Nov 13 '18 at 6:37