-3

我有一个可以使用 fetch 数组显示结果的页面。因为我在NINS-LEC页面中添加了一个字段列,所以我很难从另一个数据库表中保存它。我怎么解决这个问题?

<html>
<head>   
</head>
<body>
<?php
$server = mysql_connect("localhost","root", "");
$db =  mysql_select_db("bsswebtool",$server);
$query = mysql_query("select * from soa where InvoiceAccNum  in 
('7000068191',
'7000068205',
'7000068060',
'7000068094',
'7000068078',
'7000068086',
'7000068311',
'7000068019',
'7000068299')");
$num_rows = mysql_num_rows($query);
    ?>
    <table class="striped">
        <tr class="header">
            <td>Groupings</td>
            <td>InvoiceAccNum</td>
            <td>AccountFirstName</td>
            <td>SubsidiaryCode</td>
            <td>HandlingCode</td>

        </tr>
        <?php
           while ($row = mysql_fetch_array($query)) {
               echo "<tr>";
               echo "<td>".'NINS_LEC'."</td>"; //change group name
               echo "<td>".$row['InvoiceAccNum']."</td>";
               echo "<td>".$row['AccountFirstName']."</td>";
               echo "<td>".$row['SubsidiaryCode']."</td>";
               echo "<td>".$row['HandlingCode']."</td>";
               echo "</tr>";
           }
        ?>
    </table>
       <?echo "$num_rows Rows\n";?>
 <? echo 
"<fieldset>
<table width='680'><tr>
<td colspan='4' align='center'>
<input type='submit' name='btn_save' value='Save'>
</td></tr></table></fieldset></form>";
}?>

</body>

这是我将其保存到新表的代码 $query_insert_outbound = "INSERT INTO NINS_LEC (rid,invoiceno,grouping,Address,Subscribercode,AccountTitle,AccountFirstName,InvoiceAccNum,InvoiceNumber,HandlingCode,SubsidiaryCode,LastBillBal,CurrentCharges,TotalDueAmt,Rental_othrC,VatTag, UsageTag,OctTag,BalanceCarryFwd,PaymentReceived,Adjustments,Current,Over30days,Over60days,Over90days,Over120Days,CreditLimit,WithoutTaxTag,InvoiceCurrency,ExchangeRate,AsOnDate) values('','$invoiceno', '$grouping', '$Address' , '$Subscribercode', '$AccountTitle', '$AccountFirstName', '$InvoiceAccNum', '$InvoiceNumber', '$HandlingCode','$SubsidiaryCode'、'$LastBillBal'、'$CurrentCharges'、'$TotalDueAmt'、'$Rental_othrC'、'$VatTag'、'$UsageTag'、'$OctTag'、'$BalanceCarryFwd'、'$PaymentReceived'、 '$Adjustments', '$Current', '$Over30days', '$Over60days', '$Over90days', '$Over120Days', '$CreditLimit', '$WithoutTaxTag', '$InvoiceCurrency', '$ExchangeRate', '$AsOnDate')";

    mysql_select_db("bsswebtool",$server);  
    $server = mysql_connect("localhost","root", "");            
    $insert_query_query =mysql_query($query_insert_outbound) or die(mysql_error());
   $insert_rows_affected= mysql_num_rows($insert_query_query);
//echo $query_insert_outbound;?>

这只是我从表查询中获取数据的示例代码。我需要将结果保存到其他表,谢谢。

4

1 回答 1

0

我希望,您已经可以从中保存,您需要在表单中声明字段。表单帖子希望显示表单字段,在您的情况下,这不会发生,因为您只是在表中显示数据。也许您可以采取以下方法(请注意,我已将 TD 元素更改为表单元素:

<html>
<head>   
</head>
<body>
<?php
$server = mysql_connect("localhost","root", "");
$db =  mysql_select_db("bsswebtool",$server);
$query = mysql_query("select * from soa where InvoiceAccNum  in 
('7000068191',
'7000068205',
'7000068060',
'7000068094',
'7000068078',
'7000068086',
'7000068311',
'7000068019',
'7000068299')");
$num_rows = mysql_num_rows($query);
    ?>
    <form name="vw_ob_save" method="post">
    <table class="striped">
        <tr class="header">
            <td>Groupings</td>
            <td>InvoiceAccNum</td>
            <td>AccountFirstName</td>
            <td>SubsidiaryCode</td>
            <td>HandlingCode</td>

        </tr>
        <?php
           while ($row = mysql_fetch_array($query)) {
               echo "<tr>";
               echo "<td>".'NINS_LEC'."</td>"; //change group name
               echo "<td><input type=\"text\" name=\"invoice_num\" value=\"". stripslashes($row['InvoiceAccNum']) ."\" /></td>";
               echo "<td><input type=\"text\" name=\"first_name\" value=\"". stripslashes($row['AccountFirstName']) . "\" /></td>";
               echo "<td><input type=\"text\" name=\"subs_code\" value=\"". stripslashes($row['SubsidiaryCode']) ."\" /></td>";
               echo "<td><input type=\"text\" name=\"handling_code\" value=\"" . stripslashes($row['HandlingCode']) . "\" /></td>";
               echo "</tr>";
           }
        ?>
    </table>
       <?echo "$num_rows Rows\n";?>
 <? echo 
<table width='680'><tr>
<td colspan='4' align='center'>
<input type='submit' name='btn_save' value='Save'>
</td></tr></table>
</form>";
}?>

</body>

如果您在这方面需要进一步的帮助,请告诉我。

于 2013-09-20T03:12:17.317 回答