Hi all...here is the code of a search page in my site (it looks into mysql tables to retrieve soccer players of the fantasy league):
<?php
//trims received data from form on search.html
$keyword = trim($keyword);
$keyword = addslashes($keyword);
//database connection variables
$host = "localhost";
$user = "fan";
$password = "";
$dbname = "fan_db";
$tablename = "$type";
$link = mysql_connect($host, $user, $password);
$query = "SELECT * FROM $type LEFT JOIN squadre ON squadre.id_s = $type.id_s WHERE $tipo LIKE '".$keyword."%' ORDER BY ruolo DESC";
$result = mysql_db_query ($dbname, $query, $link);
$num_results = mysql_num_rows($result);
$keyword = stripslashes($keyword);
print("La tua ricerca per <strong>\"$keyword\"</strong> ha prodotto: <strong>".$num_results."</strong> risultati<br /><br />\n");
for ($i=0; $i <$num_results; $i++)
{
$row = mysql_fetch_array($result);
print("<strong>Ruolo:</strong> $row[ruolo]<br />\n");
print("<strong>Giocatore:</strong> $row[nome]<br />\n");
print("<strong>Venduto:</strong> $row[venduto]<br />\n");
print("<strong>Squadra di Serie A:</strong> $row[nome_A]<br />\n");
print("<strong>Fantasquadra:</strong> $row[nome_s]<br />\n");
}
if ($num_results==0) {
print("Nessun dato corrisponde...riprova!<br /><br />\n");
}
mysql_close($link);
?>
the variables $type and $tipo of the SELECT comes from an HTML FORM
I have a problem in the $row[venduto]: the mysql table return VERO or FALSO (true or false) so the output in the page return:
VENDUTO : VERO (or FALSO) (it means SOLD:true (or false))
I would like to change it to YES or NO without having to modify the DB table....
is it possible (and in case the answer is yes...HOW) to assign it to a variable (for example $venduto) and use
IF ($venduto = 'TRUE')
$stato = 'YES'
ELSE
$stato = 'NO'
and have the $stato variable in the output ????
hope you will understand my request...
thanx
Roberto