I have a MySQL (v. 3.23.41) data base and a PHP (v. 4) file that collects information from this data base.
Say, there is a table named TBL in the data base, in which there are fields FIELD1, FIELD2.
I write the following in my PHP request:
-------beginning------
$query = "select FIELD1, FIELD2
from TBL";
$result = mysql_query ($query)
or die ("Query failed"
while ($row = mysql_fetch_array ($result))
printf ("%s %s<br>\n", $row["FIELD1"], $row["FIELD2"
-------end------
I would like MySQL to do the following (but I do not manage to write the correct code):
if FIELD1 = 1 to export it to PHP like, lets say, "Peter";
if FIELD1 = 2 to export it to PHP like "Paul";
if FIELD1 = 3 to export it to PHP like "John";
if FIELD1 has any other value to export it to PHP like "Jesus".
How should I write the correct code?
Thank you in advance for your answer.
Say, there is a table named TBL in the data base, in which there are fields FIELD1, FIELD2.
I write the following in my PHP request:
-------beginning------
$query = "select FIELD1, FIELD2
from TBL";
$result = mysql_query ($query)
or die ("Query failed"
while ($row = mysql_fetch_array ($result))
printf ("%s %s<br>\n", $row["FIELD1"], $row["FIELD2"
-------end------
I would like MySQL to do the following (but I do not manage to write the correct code):
if FIELD1 = 1 to export it to PHP like, lets say, "Peter";
if FIELD1 = 2 to export it to PHP like "Paul";
if FIELD1 = 3 to export it to PHP like "John";
if FIELD1 has any other value to export it to PHP like "Jesus".
How should I write the correct code?
Thank you in advance for your answer.