Thanks Scottd,
The program runs fine, and with a link which performs a search with a distinct field!
Here is the code for anyone who is interested:
<?
//define variables to connect
$dbname = "db name";
$dbhost = "host";
$dbuser = "your user";
$dbpass = "your pass";
$conn = mysql_pConnect($dbhost,$dbuser,$dbpass);
// connect to server
$mysql_link = $conn;
// select the 'store' database
mysql_select_db($dbname, $mysql_link);
if(strlen($keyword)>1)
$keyword = $keyword . "%";
//I'm going to use two tables in the query
$table1 = "nomencla";
$table2 = "labora";
if($keyword)
{
$query = "LIKE";
$campo = "nomgen";
}
//In the second search, I'll use a distinct field
if($title)
{
$query = "=";
$keyword = $title;
$campo = "codesp";
}
//so now you do your query..
$sql = mysql_query("SELECT * FROM $table1,$table2 WHERE
labora=clab and $campo $query '$keyword'");
//and in you results you have he link display the link
while($row = mysql_fetch_row($sql))
{
$cod = $row[0];
$lab = $row[1];
$estado = $row[2];
$gt = $row[3];
$pvp = $row[4];
$title = $row[5];
$nomesp = $row[6];
$fbaja = $row[7];
$generico = $row[8];
$fbaja = $row[7];
$generico = $row[8];
$nomlab = $row[11];
//show result as link or different if it's the second query
if($campo=="nomgen")
{
print ("<a href='$PHP_SELF?title=$cod'>
$title $nomesp</a>");
print ("<BR>");
}
else
{
print("<FONT FACE=arial COLOR=red SIZE=+1>");
print ("<a href='$PHP_SELF?title=$cod'></a>
CODIGO NACIONAL: $cod <BR>
NOMBRE: $title $nomesp <BR>
PVP: $pvp <BR>
GENERICO: $generico <BR>
SITUACION: $estado <BR>
LABORATORIO: $nomlab <BR>");
SITUACION: $estado <BR>
LABORATORIO: $nomlab <BR>");
print("</FONT>");
}
}
If you think it could be improved, tell me please.
Thanks a lot.
Antonio.