Geg1
Kappa
Verificación en dos pasos activada
Verificado por Whatsapp
¡Ha verificado su Paypal!
Verificado por Binance
<table width="712" border="0">
<?php do { ?>
<tr>
<td width="129"><?php echo $row_Pedidos['id_pedido']; ?></td>
<td width="100"><?php echo $row_Pedidos['fecha']; ?></td>
<td width="107"><?php echo $row_Pedidos['cliente_id']; ?></td>
<td width="130"><?php echo $row_Pedidos['producto_id']; ?></td>
<td width="160" widht="20">
<td width="60" widht="20"> </td>
</tr>
<?php } while ($row_Pedidos = mysql_fetch_assoc($Pedidos)); ?>
</table>
<?php
$link = mysqli_connect("localhost", "root", "");
mysqli_select_db($link, "gestorpedidos");
$tildes = $link->query("SET NAMES 'utf8'");
$result = mysqli_query($link, "SELECT * FROM clientes");
while ($row_Cliente = mysqli_fetch_array($result)){
$row_Cliente [ $row_Cliente["id_cliente"] ] =$row_Cliente["nombre"];
}
mysqli_free_result($result);
mysqli_close($link);
?>
<table width="712" border="0">
<?php do { ?>
<tr>
<td width="129"><?php echo $row_Pedidos['id_pedido']; ?></td>
<td width="100"><?php echo $row_Pedidos['fecha']; ?></td>
<td width="107"><?php echo $row_Cliente[$row_Pedidos['cliente_id']]; ?></td>
<td width="130"><?php echo $row_Pedidos['producto_id']; ?></td>
<td width="160" widht="20">
<td width="60" widht="20"> </td>
</tr>
<?php } while ($row_Pedidos = mysql_fetch_assoc($Pedidos) ); ?>
</table>
Tienes un relajo de código, exactamente que quieres hacer? buscar en la tabla de pedidos los pedidos del cliente usando su nombre? de ser asi postea aqui la estructura de la tabla en MYSQL para verla (tanto de clientes como de pedidos)
Debes usar Join para eso.
SQL Joins
$result = mysqli_query($link, "SELECT * FROM clientes");
$result = mysqli_query($link, "SELECT * FROM clientes INNER JOIN pedidos ON clientes.id_cliente = pedidos.cliente_id ");
Debes usar Join para eso.
SQL Joins
<?php
$MySQLi = mysqli_connect("localhost", "root", "pass", "gestorpedidos");
$Result = $MySQLi->query("SELECT * FROM clientes INNER JOIN pedidos ON clientes.id_cliente = pedidos.cliente_id");
?>
<table style="width:712px;border:0">
<? while($clientInfo = $Result->fetch_assoc()){?>
<tr>
<td><?=$clientInfo['id_pedido']?></td>
<td><?=$clientInfo['fecha']?></td>
<td><?=$clientInfo['cliente_id']?></td>
<td><?=$clientInfo['producto_id']?></td>
</tr>
<? } ?>
</table>
PHP:<?php $MySQLi = mysqli_connect("localhost", "root", "pass", "gestorpedidos"); ?> <table style="width:712px;border:0"> <? while($clientInfo = $MySQLi->query("SELECT * FROM clientes INNER JOIN pedidos ON clientes.id_cliente = pedidos.cliente_id")->fetch_assoc()){?> <tr> <td><?=$clientInfo['id_pedido']?></td> <td><?=$clientInfo['fecha']?></td> <td><?=$clientInfo['cliente_id']?></td> <td><?=$clientInfo['producto_id']?></td> </tr> <? } ?> </table>
Así te va a quedar más "limpio".
query("SELECT * FROM clientes")->fetch_assoc()){?>
Notice: Undefined variable: clientInfo in C:\xampp\htdocs\xxxxxx\listadepedido.php on line 66
Notice: Undefined variable: clientInfo in C:\xampp\htdocs\xxxxx\listadepedido.php on line 67
Notice: Undefined variable: clientInfo in C:\xampp\htdocs\xxxxx\listadepedido.php on line 68
Notice: Undefined variable: clientInfo in C:\xampp\htdocs\xxxxx\listadepedido.php on line 69
<?php require_once('Connections/BDPedido.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_BDPedido, $BDPedido);
$query_Cliente = "SELECT * FROM clientes ORDER BY id_cliente ASC";
$Cliente = mysql_query($query_Cliente, $BDPedido) or die(mysql_error());
$row_Cliente = mysql_fetch_assoc($Cliente);
$totalRows_Cliente = mysql_num_rows($Cliente);
mysql_select_db($database_BDPedido, $BDPedido);
$query_Producto = "SELECT * FROM productos ORDER BY id_producto ASC";
$Producto = mysql_query($query_Producto, $BDPedido) or die(mysql_error());
$row_Producto = mysql_fetch_assoc($Producto);
$totalRows_Producto = mysql_num_rows($Producto);
mysql_select_db($database_BDPedido, $BDPedido);
$query_Pedidos = "SELECT * FROM pedidos ORDER BY id_pedido ASC";
$Pedidos = mysql_query($query_Pedidos, $BDPedido) or die(mysql_error());
$row_Pedidos = mysql_fetch_assoc($Pedidos);
$totalRows_Pedidos = mysql_num_rows($Pedidos);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Lista de Pedidos</title>
</head>
<body>
<?php
$MySQLi = mysqli_connect("localhost", "root", "", "gestorpedidos");
?>
<table style="width:712px;border:0">
<? while($clientInfo = $MySQLi->query("SELECT * FROM clientes")->fetch_assoc()){?>
<tr>
<td><?=$clientInfo['id_pedido']?></td>
<td><?=$clientInfo['fecha']?></td>
<td><?=$clientInfo['cliente_id']?></td>
<td><?=$clientInfo['producto_id']?></td>
</tr>
<? } ?>
</table>
</body>
</html>
<?php
mysql_free_result($Cliente);
mysql_free_result($Producto);
mysql_free_result($Pedidos);
?>
<?php
$MySQLi = mysqli_connect("localhost", "root", "pass", "gestorpedidos");
$Result = $MySQLi->query("SELECT * FROM clientes INNER JOIN pedidos ON clientes.id_cliente = pedidos.cliente_id");
?>
<table style="width:712px;border:0">
<? while($clientInfo = $Result->fetch_assoc()){?>
<tr>
<td><?=$clientInfo['id_pedido']?></td>
<td><?=$clientInfo['fecha']?></td>
<td><?=$clientInfo['cliente_id']?></td>
<td><?=$clientInfo['producto_id']?></td>
</tr>
<? } ?>
</table>
A qué te refieres con "afuera"? Y porque no funciona en xampp? 🙁PHP:<?php $MySQLi = mysqli_connect("localhost", "root", "pass", "gestorpedidos"); $Result = $MySQLi->query("SELECT * FROM clientes INNER JOIN pedidos ON clientes.id_cliente = pedidos.cliente_id"); ?> <table style="width:712px;border:0"> <? while($clientInfo = $Result->fetch_assoc()){?> <tr> <td><?=$clientInfo['id_pedido']?></td> <td><?=$clientInfo['fecha']?></td> <td><?=$clientInfo['cliente_id']?></td> <td><?=$clientInfo['producto_id']?></td> </tr> <? } ?> </table>
Disculpa se me pasó que la consulta debe estar afuera jaja, igual es posible que no te funcione en XAMPP.
Utilizamos cookies y tecnologías similares para los siguientes fines:
¿Aceptas las cookies y estas tecnologías?
Utilizamos cookies y tecnologías similares para los siguientes fines:
¿Aceptas las cookies y estas tecnologías?