gpt4 book ai didi

php - 嵌套的 while 循环不起作用,而是显示意外的 '}'

转载 作者:行者123 更新时间:2023-11-29 22:26:30 25 4
gpt4 key购买 nike

我使用嵌套 while 循环使用 php 从 sql 中的 2 个不同表中检索数据,但浏览器仅显示意外的“}”。我还尝试将嵌套 while 循环设置为注释,它在浏览器中执行得很好。我检查了每个“}”,“;” 、“”“和“'”,因为我认为这可能是问题所在,但我没有看到代码有任何问题。你能帮我吗。谢谢。

    <?php
include '../connect.php';

$SQL=mysql_query("SELECT * FROM subscribers ORDER BY Name");

while($row=mysql_fetch_array($SQL))
{
?>
<body>

<div id="page-wrap">

<textarea id="header">SARIAYA CABLE NETWORK</textarea>

<div id="identity">

<textarea id="address">Name: <?php echo $row['Name'];
$name = $row['Name']; ?>

Street: <?php echo $row['Street']; ?>

Brgy/Sitio/Subd: <?php echo $row['Brgy/Sitio/Subd']; ?>

</textarea>

<div id="logo">

<div id="logoctr">
<a href="javascript:;" id="change-logo" title="Change logo">Change Logo</a>
<a href="javascript:;" id="save-logo" title="Save changes">Save</a>
|
<a href="javascript:;" id="delete-logo" title="Delete logo">Delete Logo</a>
<a href="javascript:;" id="cancel-logo" title="Cancel changes">Cancel</a>
</div>

<div id="logohelp">
<input id="imageloc" type="text" size="50" value="" /><br />
(max width: 540px, max height: 100px)
</div>
<img id="image" src="images\logo.png" alt="logo" style="height:7vw; width:7vw;" />
</div>

</div>

<div style="clear:both"></div>

<div id="customer">

<textarea id="customer-title">Billing as of <?php echo date('F Y'); ?></textarea>

<table id="meta">
<tr>
<td class="meta-head">Account #</td>
<td><textarea><?php echo $row['Account_No.']; ?></textarea></td>
</tr>
<tr>

<td class="meta-head">Date of Billing</td>
<td><textarea id="date"><?php echo date('F d Y'); ?></textarea></td>
</tr>
<tr>
<td class="meta-head">Amount Due</td>
<td><div class="due"></div></td>
</tr>

</table>

</div>

<table id="items">

<tr>
<th>Date</th>
<th>Monthly</th>
<th>Installation</th>
<th>Transfer</th>
<th>Reconnection</th>
<th>Extension</th>
<th>Misc. fee</th>
</tr>
<?
$SQLBill=mysql_query("SELECT * FROM billing WHERE Name='$name'");

while($subrow=mysql_fetch_array($SQLBill)){
?>
<tr class="item-row">
<td class="item-name"><div class="delete-wpr"><textarea> <?php echo $subrow['Date']; ?></textarea><a class="delete" href="javascript:;" title="Remove row">X</a></div></td>
<td class="description"><textarea> <?php echo $subrow['Monthly']; ?></textarea></td>
<td><textarea class="cost"><?php echo $subrow['Installation']; ?></textarea></td>
<td><textarea class="qty"><?php echo $subrow['Reconnection']; ?></textarea></td>
<td><span class="price"><?php echo $subrow['Transfer']; ?></span></td>
<td><?php echo $subrow['Extension']; ?></td>
<td><?php echo $subrow['Misc']; ?></td>
</tr>

<tr id="hiderow">
<td colspan="7"><a id="addrow" href="javascript:;" title="Add a row">Add a row</a></td>
</tr>

<tr>
<td colspan="3" class="blank"> </td>
<td colspan="3" class="total-line">Subtotal</td>
<td class="total-value"><div id="subtotal"></div></td>
</tr>
<tr>

<td colspan="3" class="blank"> </td>
<td colspan="3" class="total-line">Total</td>
<td class="total-value"><div id="total"></div></td>
</tr>
<tr>
<td colspan="3" class="blank"> </td>
<td colspan="3" class="total-line">Amount Paid</td>

<td class="total-value"><textarea id="paid">$0.00</textarea></td>
</tr>
<tr>
<td colspan="3" class="blank"> </td>
<td colspan="3" class="total-line balance">Balance Due</td>
<td class="total-value balance"><div class="due"></div></td>
</tr>

</table>

<div id="terms">
<h5>Terms</h5>
<textarea>NET 30 Days. Cutting of service will be made on unpaid balances after 30 days.</textarea>
</div>

</div>

</body>
<?php
}//open of second php
}//close of while


mysql_close($local);
mysql_close($network);



?>

最佳答案

<? // add here like <?php
$SQLBill=mysql_query("SELECT * FROM billing WHERE Name='$name'");

while($subrow=mysql_fetch_array($SQLBill)){
?>

这里你可以在打开时添加php

在结束循环时删除 } 后面的分号

</table>

<div id="terms">
<h5>Terms</h5>
<textarea>NET 30 Days. Cutting of service will be made on unpaid balances after 30 days.</textarea>
</div>

</div>

此代码部分应该位于第一个 while 循环结束之后。并且

</body>should be at the end.

关于php - 嵌套的 while 循环不起作用,而是显示意外的 '}',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30230035/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com