php - displays data with a different sign from the database

621

coding to show the lights that are unlike any other

if the data in the database has a value of 1 then the character will appear glowing lights whereas if the data in the database has a value of 0 is the emerging light is not glowing.

illustrations like the link below picture:

pic

help me please

127

Answer

Solution:

There are multiple ways to do this, here's one approach:

<img src="/path/to/images/<?= $data ? 'img1.png' : 'img0.png' ?>" ... />

You could also write a function that outputs different images depending on the value, that's completely up to you. You have to give us some code if you want a more precise answer. Also, I don't know how you are generating your table. $data is the value of the column you described.

207

Answer

Solution:

in your SQL query you can haveSELECT CASE WHEN condition THEN 1 ELSE 0 END as someParameter FROM ...

and then in your code check for the someParameter value and display different image according to its value.

Look at the documentations for more information (I'm assuming you're using mysql)

People are also looking for solutions to the problem: php - Warning while exporting DB using phpMyAdmin

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.