Respuesta: Encontrar en la BD solo con una parte de lo almacenado es muy sencillito,lo busco y lo saco como si fuera una lista por pantalla.. global $HTTP_POST_VARS;
global $MySQL;
$firstname = $HTTP_POST_VARS['firstname_html'];
$lastname = $HTTP_POST_VARS['lastname_html'];
$table_id = R4decrypt($HTTP_POST_VARS['custolist']);
//prueba=permission( $firstname);
$tpl = new FastTemplate(".");
$tpl->define(array("main" => $scriptname));
//conditions to do the correct query
if ((empty($firstname)) and (empty($lastname)) and ($table_id>0))
{
$sql = "select title, cus_id, firstname, surname, company, address, postcode, tel, mobile_phone, fax, email, country
from customers
where (cus_id = '$table_id')";
$result = send_sql($MySQL->db1, $sql);
}
elseif (empty($lastname))
{
$sql = "select title, firstname, surname, company, address, postcode, tel, mobile_phone, fax, email, country
from customers
where ((firstname like '".$firstname." %') or (firstname = '$firstname'))";
$result = send_sql($MySQL->db1, $sql);
}
elseif (empty($firstname))
{
$sql = "select title, firstname, surname, company, address, postcode, tel, mobile_phone, fax, email, country
from customers
where (surname = '$lastname')";
$result = send_sql($MySQL->db1, $sql);
}
else
{
$sql = "select title, firstname, surname, company, address, postcode, tel, mobile_phone, fax, email, country
from customers
where (firstname = '$firstname') and (surname = '$lastname')";
$result = send_sql($MySQL->db1, $sql);
}
$tpl->parse(result, "main");
$tpl->FastPrint(result); //print as main the correct file
if (!$result)
{
die ("Database Error");
}
$num_user=(mysql_num_rows($result)); //number of rows
//linefor separate title from text
echo('<font color=#0000A0 >_________________________________________________ __________</font>');
echo('<br></br>');
while ($num_user != 0) //while there are users...
{
While ($row = mysql_fetch_array($result)) //...write information about them
{
echo ('<b><font color=#000000></b>');
echo('<b><font style="line-height: 60%;"> <FONT SIZE="3" color=#0000A0 >Title: </FONT></b>'); echo ($row["title"]);
echo('<br></br>');
echo('<b> <FONT SIZE="3" color=#0000A0> First name: </FONT></b>'); echo ($row["firstname"]);
echo('<br></br>');
echo('<b> <FONT SIZE="3" color=#0000A0> Last name: </FONT></b>'); echo ($row["surname"]);
echo('<br></br>');
echo('<b> <FONT SIZE="3" color=#0000A0> Company: </FONT></b>'); echo ($row["company"]);
echo('<br></br>');
echo('<b> <FONT SIZE="3" color=#0000A0> Address: </FONT></b>'); echo ($row["address"]);
echo('<br></br>');
echo('<b> <FONT SIZE="3" color=#0000A0> Postcode: </FONT></b>'); echo ($row["postcode"]);
echo('<br></br>');
echo('<b> <FONT SIZE="3" color=#0000A0> Phone: </FONT></b>'); echo ($row["tel"]);
echo('<br></br>');
echo('<b> <FONT SIZE="3" color=#0000A0> Mobile Phone: </FONT> </b>'); echo ($row["mobile_phone"]);
echo('<br></br>');
echo('<b><FONT SIZE="3" color=#0000A0> Fax: </FONT></b>'); echo ($row["fax"]);
echo('<br></br>');
echo('<b><FONT SIZE="3" color=#0000A0> Email: </FONT></b>'); echo ($row["email"]);
echo('<br></br>');
echo('<b> <FONT SIZE="3" color=#0000A0> Country: </FONT></b>'); echo ($row["country"]);
echo('<br></br>');
echo('<font color=#0000A0 >_________________________________________________ __________</font>');
echo('<br></br>');
echo('<br></br>');
}
$num_user--;
}
} |