PHP Query

  FOEYDO 10:00 22 Jun 08

Hi, say I want to change something on my php page in mysql databse. For example
I want to change where it is cat in the database to display as dog on the page what is the code I use?
Hope this makes sense!

  tasslehoff burrfoot 15:09 22 Jun 08

Assuming you are storing the result of the database query in a variable named result, it would be something like this, I think:

If ($result == "cat") {
print "dog";

  FOEYDO 09:20 23 Jun 08

Thanks I will try this

  FOEYDO 11:08 25 Jun 08

Icant get this to work where would I put it and if I wanted to replace multiple items
ie replace cat with dog and black with white how would I do this?

  Taran 12:18 25 Jun 08

Why don't you put an additional field in your database containing the value of a word, and have your PHP script display the value ?

If you want to do this on many pages itwould make sense either to write a PHP include (use the same code by linking the include on each page requiring it) or simply run the query to look up a specific record an only dispay the value you want.

MySQL table:

id | item | alternative_value

1 dog cat
2 parrot budgie

Run your PHP query to look up the required record and display its alternative value rather than the record itself.

Not sure why you'd want to do this, but there we are - a few ways around it from changing the database output to a different value with PHP or selectively diaplying an alternative record value from the database, also called through PHP.

  FOEYDO 12:21 25 Jun 08

I dont want an additional table thanks need to be able to do it on the page

This thread is now locked and can not be replied to.

Surface Pro (2017) vs Surface Pro 4

20 groundbreaking 3D animation techniques

How to mine Bitcoin on Mac