I have a "Clients" table and an other called "Contacts". I have done a master/detail page, in the master page, there is the name of the client and in the detail one there is the phone, email, fax, etc. of the client. Moreover, for each client I have some contacts and that's why I have created a spry menu in the detail page that show a maximum of 4 contacts for each client. With the following sentence, the contact is printed only if he/she belongs to the client:
<?php if($row_DetailRS1['Nombre']==$row_Recordset1['Nombre de la empresa'])
{ echo $row_Recordset1['Nombre del contacto']; }?>
But the problem is that the 4 bars that the menu have, are inputed with the same contact. I give you an example:
Clients table: (Seat, 938314587, seat@gmail.com, etc); (Audi, 93564215, audi@didi.com, etc); (BMW, 93145698, bmw@m3.com, etc) Contacts table: (Nerea, Audi, 93654565, etc); (Alberto, Audi, 93654789, etc) (Marta, Seat 93145697, etc); (Oscar, Audi, 93656987, etc)
Masetr page: Audi
Detail page: Audi 93564215 audi@didi.com
SPRAY MENU Nerea Info of Nerea Alberto Info of Alberto Oscar Info of Oscar
It should be like it is above, but it becomes like that:
SPRAY MENU Nerea Info of Nerea Nerea Info of Nerea Nerea Info of Nerea
ACTUALIZATION:
I have improved a bit the code but it still doesn't work... Now it only shows me the first row of the table "Contacts", and if the first row have another client, it prints a white blanket instead of jumping to find if that sentence is true for the next row:
<?php if($row_DetailRS1['Nombre']==$row_Recordset1['Nombre de la empresa'])
{ echo $row_Recordset1['Nombre del contacto']; }?>
I put the code there:
mysql_select_db($database_localhost, $localhost);
$query_DetailRS1 = sprintf("SELECT * FROM clientes WHERE Nombre = %s", GetSQLValueString($colname_DetailRS1, "text"));
$query_limit_DetailRS1 = sprintf("%s LIMIT %d, %d", $query_DetailRS1, $startRow_DetailRS1, $maxRows_DetailRS1);
$DetailRS1 = mysql_query($query_limit_DetailRS1, $localhost) or die(mysql_error());
$row_DetailRS1 = mysql_fetch_assoc($DetailRS1);
if (isset($_GET['totalRows_DetailRS1'])) {
$totalRows_DetailRS1 = $_GET['totalRows_DetailRS1'];
} else {
$all_DetailRS1 = mysql_query($query_DetailRS1);
$totalRows_DetailRS1 = mysql_num_rows($all_DetailRS1);
}
$totalPages_DetailRS1 = ceil($totalRows_DetailRS1/$maxRows_DetailRS1)-1;
mysql_select_db($database_localhost, $localhost);
$query_Recordset1 = "SELECT * FROM contactos";
$result = mysql_query($query_Recordset1);
$Recordset1 = mysql_query($query_Recordset1, $localhost) or die(mysql_error());
<table border="0" align="center" cellpadding="10" cellspacing="2">
<tr>
<th bgcolor="#0000CC" class="tgnr">Nombre</th>
<td bgcolor="#0066FF" class="datos"><?php echo $row_DetailRS1['Nombre']; ?></td>
</tr>
<tr>
<th bgcolor="#0000CC" class="tgnr">Direccion</th>
<td bgcolor="#0066FF" class="datos"><?php echo $row_DetailRS1['Direccion']; ?></td>
</tr>
<tr>
<th bgcolor="#0000CC" class="tgnr">Ciudad</th>
<td bgcolor="#0066FF" class="datos"><?php echo $row_DetailRS1['Ciudad']; ?></td>
</tr>
<tr>
<th bgcolor="#0000CC" class="tgnr">CP</th>
<td bgcolor="#0066FF" class="datos"><?php echo $row_DetailRS1['CP']; ?></td>
</tr>
<tr>
<th bgcolor="#0000CC" class="tgnr">Pais</th>
<td bgcolor="#0066FF" class="datos"><?php echo $row_DetailRS1['Pais']; ?></td>
</tr>
<tr>
<th bgcolor="#0000CC" class="tgnr">Telefono 1</th>
<td bgcolor="#0066FF" class="datos"><?php echo $row_DetailRS1['Telefono 1']; ?></td>
</tr>
<tr>
<th bgcolor="#0000CC" class="tgnr">Telefono 2</th>
<td bgcolor="#0066FF" class="datos"><?php echo $row_DetailRS1['Telefono 2']; ?></td>
</tr>
<tr>
<th bgcolor="#0000CC" class="tgnr">Pagina web</th>
<td bgcolor="#0066FF" class="datos"><?php echo $row_DetailRS1['Pagina web']; ?></td>
</tr>
<tr>
<th bgcolor="#0000CC" class="tgnr">Fax</th>
<td bgcolor="#0066FF" class="datos"><?php echo $row_DetailRS1['Fax']; ?></td>
</tr>
<tr>
<th bgcolor="#0000CC" class="tgnr">Correo 1</th>
<td bgcolor="#0066FF" class="datos"><?php echo $row_DetailRS1['Correo 1']; ?></td>
</tr>
<tr>
<th bgcolor="#0000CC" class="tgnr">Correo 2</th>
<td bgcolor="#0066FF" class="datos"><?php echo $row_DetailRS1['Correo 2']; ?></td>
</tr>
</table>
<?php $NFilas = mysql_num_rows($result);
?>
<ul id="MenuBar1" class="MenuBarVertical">
<li><a class="MenuBarItemSubmenu" href="#"><?php for ( $i = 1; $i < $NFilas; $i++) {
if($row_DetailRS1['Nombre']==$row_Recordset1['Nombre de la empresa']){ echo $row_Recordset1['Nombre del contacto']; }}?></a>
<ul>
<li><a class="MenuBarItemSubmenu" href="#">Departamento</a>
<ul>
<li><a href="#"><?php echo $row_Recordset1['Departamento'] ?></a></li>
</ul>
</li>
<li><a class="MenuBarItemSubmenu" href="#">Teléfono</a>
<ul>
<li><a href="#"><?php echo $row_Recordset1['Telefono'] ?></a></li>
</ul>
</li>
<li><a class="MenuBarItemSubmenu" href="#">Fax</a>
<ul>
</a></li>
<li><a href="#"><?php echo $row_Recordset1['Fax'] ?></a></li>
</ul>
</li>
<li><a href="#">Email</a>
<ul>
<li><a href="#"><?php echo $row_Recordset1['Email'] ?></a></li>
</ul>
</li>
</ul>
<li><a class="MenuBarItemSubmenu" href="#"><?php for ( $i = $i; $i < $NFilas; $i++) {if($row_DetailRS1['Nombre']==$row_Recordset1['Nombre de la empresa']){ echo $row_Recordset1['Nombre del contacto']; }} ?></a>
<ul>
<li><a class="MenuBarItemSubmenu" href="#">Departamento</a>
<ul>
<li><a href="#"><?php echo $row_Recordset1['Departamento'] ?></a></li>
</ul>
</li>
<li><a class="MenuBarItemSubmenu" href="#">Teléfono</a>
<ul>
<li><a href="#"><?php echo $row_Recordset1['Telefono'] ?></a></li>
</ul>
</li>
<li><a class="MenuBarItemSubmenu" href="#">Fax</a>
<ul>
<li><a href="#"><?php echo $row_Recordset1['Fax'] ?></a></li>
</ul>
</li>
<li><a href="#">Email</a>
<ul>
<li><a href="#"><?php echo $row_Recordset1['Email'] ?></a></li>
</ul>
</li>
</ul>
</li>
<li><a class="MenuBarItemSubmenu" href="#"><?php for ( $i = $i; $i < $NFilas; $i++) {if($row_DetailRS1['Nombre']==$row_Recordset1['Nombre de la empresa']){ echo $row_Recordset1['Nombre del contacto']; }} ?></a>
<ul>
<li><a class="MenuBarItemSubmenu" href="#">Departamento</a>
<ul>
<li><a href="#"><?php echo $row_Recordset1['Departamento'] ?></a></li>
</ul>
</li>
<li><a class="MenuBarItemSubmenu" href="#">Teléfono</a>
<ul>
<li><a href="#"><?php echo $row_Recordset1['Telefono'] ?></a></li>
</ul>
</li>
<li><a class="MenuBarItemSubmenu" href="#">Fax</a>
<ul>
<li><a href="#"><?php echo $row_Recordset1['Fax'] ?></a></li>
</ul>
</li>
<li><a href="#">Email</a>
<ul>
<li><a href="#"><?php echo $row_Recordset1['Email'] ?></a></li>
</ul>
</li>
</ul>
</li>
<li><a class="MenuBarItemSubmenu" href="#"><?php for ( $i = $i; $i < $NFilas; $i++) {if($row_DetailRS1['Nombre']==$row_Recordset1['Nombre de la empresa']){ echo $row_Recordset1['Nombre del contacto']; }}?></a>
<ul>
<li><a class="MenuBarItemSubmenu" href="#">Departamento</a>
<ul>
<li><a href="#"><?php echo $row_Recordset1['Departamento'] ?></a></li>
</ul>
</li>
<li><a class="MenuBarItemSubmenu" href="#">Teléfono</a>
<ul>
<li><a href="#"><?php echo $row_Recordset1['Telefono'] ?></a></li>
</ul>
</li>
<li><a class="MenuBarItemSubmenu" href="#">Fax</a>
<ul>
<li><a href="#"><?php echo $row_Recordset1['Fax'] ?></a></li>
</ul>
</li>
<li><a href="#">Email</a>
<ul>
<li><a href="#"><?php echo $row_Recordset1['Email'] ?></a></li>
</ul>
</li>
</ul>
</li>
</ul>