-5

I am unsure what I am to search for this question so not much research has been done.

I have a MySQL table that I store scores for a pool team as 1 for a win and 0 for a loss

i am displaying the values on a table but would like to change the output into words maybe different colours depending on the value.

the value 1 i like to read Win in green and value 2 to read lose in red.

how can i do this? or can u link me to a basic tutorial

Rick Skeels
  • 513
  • 1
  • 11
  • 30
  • 2
    Read a PHP tutorial or buy a book or pay a developer. Your question should be answered in any book regarding HTML, PHP and MySQL. – AgRizzo Jan 25 '14 at 15:34
  • 1
    I did state in my question that i am unsure what i should be searching for so i haven't tried anything at moment as not sure this is 1) possible or 2) simple enough for me to understand. this is just a learning project for me so i wont be outsourcing to a developer :) – Rick Skeels Jan 25 '14 at 15:37
  • 4
    This question appears to be off-topic because it asks for introductory information on how to write a program and does not identify a specific question or problem. Please see the help page about what kinds of questions are appropriate for this site: http://stackoverflow.com/help/on-topic – Adi Inbar Jan 25 '14 at 16:07

4 Answers4

1

Perhaps you need a conditional operator: http://davidwalsh.name/php-shorthand-if-else-ternary-operators

$output="Result:".( $score ? "<font color=green>$score</font>":"<font color=red>$score</font>");
Tek Jau
  • 19
  • 3
1

You should really make an attempt before asking a question on here. Giving you the benefit of the doubt, I'd say look into enumerations (since you seem to not want to use a simple conditional for some reason)

Community
  • 1
  • 1
TonyArra
  • 10,607
  • 1
  • 30
  • 46
  • 1
    I 100% agree with you, i kinda knew i would get down votes as its not really a structured questions with attempts to sole this myself, but i was unsure what to search for, Thanks for your reply – Rick Skeels Jan 25 '14 at 15:50
0

You simply can put a condition in the table, to check the score value. Supposing you have an array of scores:

<table>
    <? foreach($score in $scores) ?>
    <tr>
        <td>some data</td>
        <td>some data</td>
        ...
        <td>
        <?
            if($score == 1) { echo "Win" } else { echo "Lose" }
        ?>
        </td>
    </tr>
</table>
S. A.
  • 3,714
  • 2
  • 20
  • 31
0

There been a lot of great answers on this question of mine but if anyone looking for a quick fix in this case the following works for me

<?php
if ($fs1 > 0) {
    echo "<p style='color:#0F3'>Win<p>";
} else {
    echo "<p style='color:#F00'>Lose<p>";
}
?>

with $fs1 being the row that i am getting the value from

Without the links within the answeres i would never of found out how to do it

Rick Skeels
  • 513
  • 1
  • 11
  • 30