我的发票结果有问题,我的问题是,如果我有多个订单,您如何重置发票数据?结果仅出现在列表的第一个订单中,似乎没有从另一行获取新数据。它不断从第一个数据中获取数据......
orders.php - 订单列表
<?php
$conn= mysqli_connect("localhost","root", "", "registration");
$sql="SELECT * FROM comenzi";
$result=mysqli_query($conn, $sql);
$queryResults= mysqli_num_rows($result);
if($queryResults > 0) {
while ($row = mysqli_fetch_assoc($result)) {
echo "<a href='article1.php?codc=".$row['codc']."&codp=".$row['codp']."'> <table border=1 bgcolor=#b3ccff>
<tr>
<th>Numar</th>
<th>Cod produs</th>
<th>Cod client</th>
<th>Data </th>
<th colspan=2><center> Actiune </th>
</tr>
<tr>
<td><p> ".$row['codc']." </p></td>
<td><p><a href='produs.php?codc=".$row['codc']."&codp=".$row['codp']."' > ".$row['codp']."</a> </p></td>
<td><p><a href='client.php?codc=".$row['codc']."&codcl=".$row['codcl']."' > " .$row['codcl']."</a> </p></td>
<td><p> " .$row['datac']." </p></td>
<td> </tr> </table>";
}
}
?>
article.php - 来自一个订单的详细信息
<?php
$codc = mysqli_real_escape_string($conn, $_GET['codc']);
$codp = mysqli_real_escape_string($conn, $_GET['codp']);
$sql = "SELECT * FROM comenzi WHERE codc='$codc' AND codp='$codp'";
$result = mysqli_query($conn, $sql);
$queryResults=mysqli_num_rows($result);
if($queryResults > 0){
while($row=mysqli_fetch_assoc($result)){
echo "<div class='article-box' >
<table border=1 bgcolor=#b3ccff>
<tr>
<th>Numar </th>
<th>Cod produs</th>
<th>Cod client</th>
<th>Data </th>
</tr>
<tr>
<td> <p> ".$row['codc']." </p>
</td>
<td> <p> <a href='produs.php?codc=".$row['codc']."&codp=".$row['codp']."' > ".$row['codp']." </a> </p>
</td>
<td> <p><a href='client.php?codc=".$row['codc']."&codcl=".$row['codcl']."' > ".$row['codcl']." </a></p>
</td>
<td> <p> ".$row['datac']." </p>
</td>
</tr> </table> </div>
<form method='post' action='article1.php'>
<div class=input-group>
<button type=submit class=btn name=view> <a href='invoice.php?codc=".$row['codc']."&codcl=".$row['codcl']."&codp=".$row['codp']."' style='color: white;' > Vezi factura </a> </button> </div>
</form>";
}
}
?>
invoice.php -
<?php
include_once 'header.php';
if ( isset($_POST['view'])){
$codc = $POST['codc'];
$codp = $POST['codp'];
$codcl = $_POST['codcl'];
$codc = mysqli_real_escape_string($conn, $_GET['codc']);
$codcl = mysqli_real_escape_string($conn, $_GET['codcl']);
$codp = mysqli_real_escape_string($conn, $_GET['codp']);
$sql="SELECT seriefc, nrfc, datac, numecl, prenumecl, state, cnp, adresacl, denp, pretp
FROM facturic
INNER JOIN comenzi
ON facturic.codc = comenzi.codc
INNER JOIN clienti
ON facturic.codcl = clienti.codcl
INNER JOIN produse
ON facturic.codp = produse.codp
WHERE codc='$codc' AND codcl='$codcl' AND codp='$codp' ";
$res= mysqli_query($conn, $sql) or die ("Nu s-a putut completa".mysqli_error($conn));
$row = $res->fetch_assoc();
//mysql_fetch_assoc($res);
}
?>
<table>
<form method="POST" action="invoice.php">
<?php
$result = mysqli_query ( $conn ,"SELECT * FROM facturic ");
$invoice = $result->fetch_assoc ();
?>
<td ><font size="1" > <b> Seria</b></font> </td>
<td><font size="1" > <?php echo $invoice['seriefc']; ?> </font> </td>
<td ><font size="1"><b> Nr factura</b></font></td>
<td><font size="1" ><?php echo $invoice['nrfc']; ?> </font></td>
<?php $result = mysqli_query ( $conn ,"SELECT * FROM comenzi WHERE codc = '{$invoice['codc']}' " );
$order = $result->fetch_assoc ();
?>
<td ><font size="1" > <b> Data </b> </font> </td>
<td><font size="1" ><?php echo $order['datac']; ?></font> </td>
<table cellspacing="0" cellpadding="0" style="border-spacing: 0;">
<?php $result = mysqli_query ( $conn ,"SELECT * FROM clienti WHERE codcl = '{$invoice['codcl']}' " );
$client = $result->fetch_assoc ();
?>
<tr> <td > <font size="1" >    <b>Furnizor:</b> S.C. ELECTRONIC WORLD SRL </font></td>
<td align="right" > <font size="1" >    <b>Cumparator(denumire, forma juridica):</b> <?php echo $client['numecl'].' '.$client['prenumecl']; ?> </font></td>
</tr>
<tr> <td > <font size="1" >    <b> Nr. ord.registru com./an:</b> J40/4364/2007</font> </td>
<td align="right" > <font size="1" >    <b>CNP:</b><?php echo $client['cnp']; ?></font></td>
</tr>
<tr> <td> <font size="1" >    <b> C.I.F.:</b> RO 21255775</font> </td>
<td align="right" > <font size="1" >    <b>Adresa:</b><?php echo $client['adresacl'] ;?> </font></td>
</tr>
<tr> <td><font size="1" >     <b> Capital social subscris si varsat:</b> 119.000 RON </font> </td>
</tr>
<tr> <td><font size="1" >    <b> BRD Sucursala Mari Clienti Corporativi (SMCC)</b></font> </td> </tr>
<tr> <td><font size="1" >     RO39 BRDE 450S V893 7500 6500</font> </td> </tr>
<tr> <td><font size="1" >     <b> Sediul:</b> Expozitiei 2,Cladirea MCAR(C9),Sector 1,Bucuresti,012103</font> </td> </tr>
<tr> <td><font size="1" >    <b> Tel:</b> +40 21 200 52 00, fax: +40 21 200 52 25</font></td> </tr>
</table>
<br>
<center>
<table style="width:850px" border="1">
<tr>
<td><center> Nr. crt. </center></td>
<td><center> Denumirea produsului sau a serviciului</center> </td>
<td><center> U.M.</center> </td>
<td> <center> Cota T.V.A.<br> -%- </center></td>
<td><center> Pret unitar <br> -lei-</center> </td>
<td><center> Valoarea T.V.A. <br> -lei</center> </td> </tr>
<?php
$result = mysqli_query ( $conn ,"SELECT * FROM produse WHERE codp= '{$invoice['codp']}' " );
$produs = $result->fetch_assoc ();
?>
<tr>
<td><center> 1.</center> </td>
<td><?php echo $produs['denp']; ?> </td>
<td><center> buc</center> </td>
<td><center>19</center> </td>
<td><center> <?php echo $produs['pretp']; ?></center> </td>
<td><center><?php echo $produs['pretp']*19/100 ;?></center></td>
</tr>
</center>
</table>
</form>
</body>
</html>