Bueno he decidido separar la consultar para poderla tratar mejor, pero al hacerlo me da error:
Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: YES) in C:\Program Files\EasyPHP-5.3.8.0\www\modelo.php on line 14
Warning: mysql_select_db() expects parameter 2 to be resource, boolean given in C:\Program Files\EasyPHP-5.3.8.0\www\modelo.php on line 15
Warning: mysql_query() expects parameter 2 to be resource, boolean given in C:\Program Files\EasyPHP-5.3.8.0\www\modelo.php on line 21
Access denied for user 'root'@'localhost' (using password: YES)
Pongo el codigo a ver si veis el fallo:
Código PHP:
Ver original<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
</head>
<body>
<?php
//Conectamos la bbdd
//seleccionamos los registros que queremos
$modelo = $_POST["modelo"];
//$queEmp = 'SELECT A.Description, A.Partnumber, B.Modelo FROM baterias AS A INNER JOIN baterias AS B ON A.Partnumber = B.Partnumber WHERE A.Modelo LIKE '.$modelo.' AND A.Partnumber LIKE "BT.%" AND A.Description LIKE "BATTERY%" ORDER BY A.Partnumber';
$queEmp = 'SELECT Description, Partnumber FROM baterias WHERE Modelo = "'.$modelo.'" AND Description LIKE "BATTERY%" ORDER BY Partnumber';
?>
<table>
<tr>
<td>Descripcion</td>
<td>Part Number</td>
<td>Modelos Compatibles</td>
</tr>
<?php
if ($totEmp> 0) {
$contador = 0;
//$temporal= "<tr><td>".$primero."</td><td>".$segundo."</td><td>".$rowEmp['B.Modelo']."</td>";
if ($contador = 0){
echo "<tr><td>".$rowEmp['Descripcion']."</td>";
echo "<td>".$rowEmp['Partnumber']."</td>";
$queEmp2 = 'SELECT Modelo FROM baterias WHERE Partnumber ='.$rowEmp['Partnumber'].'';
$i = 0;
if ($i = 0){
echo "<td>".$rowEmp2['Modelo']."</td></tr>";
$i = 1;
}else{
echo "<tr><td></td><td></td>";
echo "<td>".$rowEmp2['Modelo']."</td><tr>";
}
}
$contador = 1;
}
else{
echo "<tr><td>".$rowEmp['Descripcion']."</td>";
echo "<td>".$rowEmp['Partnumber']."</td>";
$queEmp2 = 'SELECT Modelo FROM baterias WHERE Partnumber ='.$rowEmp['Partnumber'].'';
$i = 0;
if ($i = 0){
echo "<td>".$rowEmp2['Modelo']."</td></tr>";
$i = 1;
}else{
echo "<tr><td></td><td></td>";
echo "<td>".$rowEmp2['Modelo']."</td><tr>";
}
}
}
}
}
?>
</table>
</body>
</html>