Jump to content

Returned values displayed differently?


woolyg

Recommended Posts

Hi all,

 

I've got a function in PHP that calls values from a MYSQL DB, and it returns numbers.

 

(eg. - Woolyg - 14)

 

Is there a way in PHP to substitute these numbers for worded values? So say if the function returned values 1-10 it displays the word 'Useless'... 10-20 displays 'Average'... and 20-30 displays 'Awesome'..?

 

Anyone got any idea?

Cheers,

Woolyg

Link to comment
Share on other sites

Cool, thanks guys - I'll put it into practise and see what I can come up with.

 

Do you think this would work for multiple populated numbers?

 

Say, if I had a table with a number of entries that I was calling:

 

ID  Name    Value1  Value2  Value3

1    Woolyg    14        7          28

 

and used

 

$query = mysql_query(SELECT * FROM table");
$show = mysql_fetch_ros($query);

if($show){
echo "$show[1]<br>";
echo "$show[2]<br>";
echo "$show[3]<br>";
echo "$show[3]<br>";
}

 

..would that work? - And additionally, would I be able to use the same code barand posted above and link it to a different query?

 

 

Link to comment
Share on other sites

To explain above:

The query returns a row, from which I select returned values 1, 2, 3 and 4

 

If $show[1] returned the value 5, I'd like to display the word "Useless"

If $show[2] returned the value 15, I'd like to display the word "Average"

If $show[3] returned the value 25, I'd like to display the word "Awesome"

 

 

.. get me? I hope my code-addled brain is able to explain properly..

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.