Hola foreros,necesito ayuda,lo he pedido un par de veces pero nadie me contesta

o no me explico bien,o es dificil lo que pido pero algo falla...jejeje Es un poco largo pero espero encontrar algun alma caritativa
Creo que realmente es sencillo pero llevo 3 dias y no lo soluciono:
Lo unico que tengo que hacer es coger unos valores de una base de datos y sacarlos por pantalla en un template,mi problema es que solo escribo una tabla con los datos del cliente cuando me deberian de salir una por cada uno de ellos,eso no se hacerlo.Como es que en una consulta salen varios?Porque puede haber varias personas con el mismo nombre en la base de datos.La idea es mostrar por pantalla uno a continuacion del otro.
Metes firstname y lastname t lo busca en la base de datos y lo mete en el template..
codigo:
Esta es la funcion que coge los datos de la DB y los meto en el template:
************************************************** *****
function Insertion_Search($scriptname)
{
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]);
$tpl = new FastTemplate(".");
$tpl->define(array("main" => $scriptname));
if ((empty($firstname)) and (empty($lastname)) and ($table_id>0))
{
$sql = "select 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 firstname, surname, company, address, postcode, tel, mobile_phone, fax, email, country
from customers
where (firstname = '$firstname')";
$result = send_sql($MySQL->db1, $sql);
}
elseif (empty($firstname))
{
$sql = "select 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 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);
}
//if($row=mysql_fetch_array($result))
if (!$result)
{
die ("Database Error");
}
$num_user=(mysql_num_rows($result));
while ($num_user != 0)
{
echo($num_user);
while ($value=mysql_fetch_array($result))
{
$tpl->assign(FIRST_VALUE, $value["firstname"]);
$tpl->assign(LAST_VALUE, $value["surname"]);
$tpl->assign(COMPANY_VALUE, $value["company"]);
$tpl->assign(ADDRESS_VALUE, $value["address"]);
$tpl->assign(POSTCODE_VALUE, $value["postcode"]);
$tpl->assign(TEL_VALUE, $value["tel"]);
$tpl->assign(MOBILE_PHONE_VALUE,$value["mobile_phone"]);
$tpl->assign(FAX_VALUE, $value["fax"]);
$tpl->assign(EMAIL_VALUE, $value["email"]);
$tpl->assign(COUNTRY_VALUE, $value["country"]);
}
$num_user--;
}
$tpl->parse(result, "main");
$tpl->FastPrint(result);
}
[/SIZE][/COLOR]
************************************************** ***** este es el template donde meto los datos *******************************************
<html><head>
<title>show</title>
<link href="templates/style/buttons.css" type=text/css rel=stylesheet>
<link href="templates/style/W3C-REC.css" type=text/css rel=stylesheet>
<script>
function recall(form){
window.location.href = "search_customer.php?id="+document.forms[0].elements['cus_id'].value+"&serv="+document.forms[0].elements['name_service_html'].value;
//alert (document.forms[0].elements['cus_id'].value+"&serv="+document.forms[0].elements['name_service_html'].value);
}
</script>
<body textcolor=white background="images/topBG2.png">
<p align=LEFT>
<form name = "nuevo" action = "{SCRIPT}" method = "POST">
<input type=hidden name=cus_id value='{CUSTOMER}'>
<table width = 535 height="1" bordercolor="#000080" border="0">
<tr>
<td align = left width="33" valign="top" height="40" bgcolor="#000080">
</td>
<td align = left width="637" valign="top" height="40" bgcolor=darkblue>
<font size="5" color="#FFFFFF" face="Arial Black"><h1>{NAME}</h1></font>
</td>
</tr>
<tr>
<td align = left width="33" valign="top" height="1">
</td>
<td align = left width="637" valign="top" height="1">
</td>
</tr>
<tr>
<td align = left width="33" valign="top" height="13" bgcolor="#000099">
</td>
<td align = left width="637" valign="top" height="13" bgcolor="#000099">
<font color="#FFFFFF" face="Arial Black">Company Profile</font>
</td>
</tr>
<tr>
<td align = left width="33" valign="top" height="1">
</td>
<td align = left width="637" valign="top" height="1">
</td>
</tr>
<tr>
<td align = left width="33" valign="top" height="1">
</td>
<td align = left width="637" valign="top" height="1">
<table border="1" width="99%">
<tr>
<td width="30%"><font color=black color=white face="Times New Roman, Times, serif"><B>Company (Project)
Name {COMPANY}</B></font></td>
<td width="70%"><font color=white color=white face="Times New Roman, Times, serif"><input type = "text" name = "company_name_html" value="{COMPANY_VALUE}" size = "120" maxlength = "255" tabindex=1 >
</font> </td>
</tr>
<tr>
<td width="30%"><font color=black color=white face="Times New Roman, Times, serif" ><B> Address {ADDRESS}</B></font></td>
<td width="70%"><font color=white color=white face="Times New Roman, Times, serif"><input type = "text" name = "address_html" value="{ADDRESS_VALUE}"size = "120" maxlength = "255"tabindex=2>
</font>
</td>
</tr>
<tr>
<td width="30%"><font color=black color=white face="Times New Roman, Times, serif"><B>Postcode {POSTCODE}</B></font></td>
<td width="70%"><font color=white color=white face="Times New Roman, Times, serif"><input type = "text" name = "postcode_html" value="{POSTCODE_VALUE}"size = "120" maxlength = "255"tabindex=3>
</font>
</td>
<tr>
<td width="30%"><font color=black color=white face="Times New Roman, Times, serif"><B>Telephone {TEL}</B></font></td>
<td width="70%"><font color=white color=white face="Times New Roman, Times, serif"><input type = "text" name = "tel_html" value="{TEL_VALUE}"size = "120" maxlength = "255" tabindex=4>
</font>
</td>
</tr>
<tr>
<td width="30%"><font color=black color=white face="Times New Roman, Times, serif"><B> Fax {FAX}</B></font></td>
<td width="70%"><font color=white color=white face="Times New Roman, Times, serif"><input type = "text" name = "fax_html" value="{FAX_VALUE}" size = "120" maxlength = "255" tabindex=5>
</font>
</td>
</tr>
<tr>
<td width="30%"><font color=black color=white face="Times New Roman, Times, serif"> <B>Country</B> </font></td>
<td width="70%"><font color=white color=white face="Times New Roman, Times, serif"><input type = "text" name = "country_html" value="{COUNTRY_VALUE}" size = "120" maxlength = "255" tabindex=5>
{COUNTRY}
</select>
</td>
</tr>
</table>
<p>
</td>
</tr>
<tr>
<td align = left width="33" valign="top" height="13" bgcolor="#000099">
</td>
<td align = left width="637" valign="top" height="13" bgcolor="#000099">
<font color="#FFFFFF" face="Arial Black">Contact Person</font>
</td>
</tr>
<tr>
<td align = left width="33" valign="top" height="1">
</td>
<td align = left width="637" valign="top" height="1">
</td>
</tr>
<tr>
<td align = left width="33" valign="top" height="1">
</td>
<td align = left width="637" valign="top" height="1">
<table border="1" width="99%">
<tr>
<td width="30%"><font color="black" face="Times New Roman, Times, serif"><B>First
Name {FIRST}</B></font></td>
<td width="70%"><font color=white color=white face="Times New Roman, Times, serif">
<input type = "text" name = "firstname_html" value="{FIRST_VALUE}" size = "30" maxlength = "50"tabindex=7>
</font>
</td>
</tr>
<tr>
<td width="30%"><font color="black" face="Times New Roman, Times, serif"><B>Last
Name {LAST}</B></font></td>
<td width="70%"><font color=white color=white face="Times New Roman, Times, serif"><input type = "text" name = "lastname_html" value="{LAST_VALUE}" size = "30" maxlength = "70"tabindex=8>
</font>
</td>
</tr>
<tr>
<td width="30%"><font color="black" face="Times New Roman, Times, serif"><B>E-mail
Address {EMAIL}</B></font></td>
<td width="70%"><font color=white color=white face="Times New Roman, Times, serif">
<input type = "text" name = "email_html" value="{EMAIL_VALUE}" size = "30" maxlength = "70"tabindex=9>
</font>
</td>
</tr>
</table>
<p>
</td>
</tr>
</form>
</body></html>
************************************************** **