0
我試圖建立一個使用PHP將數據從MSSQL數據庫插入到我正在構建的網站的頁面的動態表。每個可見行代表個人薪水。每行下面是與之相關的細節。這很容易納稅,因爲數據在每張支票的主表格行內都保存着。現在我需要添加扣減,問題是,對於每個支票號碼,我會得到多行詳細扣除。使用PHP和SQL創建多語句動態表使用PHP和SQL
我可以在while循環中切換SQL語句,但當完成後切換回原來的格式?
或者是這個工作的混亂外加入了一些其他類型的SQL巫術的....
這是我現在有代碼的樣本。
while ($row = mssql_fetch_array($rs))
{
$paychecknum =$row['check_no'];
$paycheckdate=$row['check_date'];
$netpay=$row['check_amount'];
$grosspay=$row['gross_pay'];
$tax=$row['taxes'];
$deductions=$row['deductions'];
$fit=$row['fit'];
$lit=$row['lit'];
$sit=$row['sit'];
$fica=$row['fica'];
echo('<div class="row">');
echo('<div class="cell">Check Date:');
echo $paycheckdate;
echo('</div>');
echo('<div class="cell">Check Number: ');
echo $paychecknum;
echo('</div>');
echo('<div class="cell">Gross Pay: ');
echo $grosspay;
echo('</div>');
echo('<div class="cell clickable" onClick="showAmount('.$paychecknum.')"> Taxes: ');
echo $tax;
echo('</div>');
echo('<div class="cell clickable" onClick="showAmount(1'.$paychecknum.')">Deductions: ');
echo $deductions;
echo('</div>');
echo('<div class="cell">Net Pay: ');
echo $netpay;
echo('</div>');
echo('</div>');
echo('<div class="row hidden" id="'.$paychecknum.'">');
echo('<div class="cell">Federal Income Tax: ');
echo $fit;
echo('</div>');
echo('<div class="cell">Local Income Tax: ');
echo $lit;
echo('</div>');
echo('<div class="cell">State Income Tax: ');
echo $sit;
echo('</div>');
echo('<div class="cell">FICA: ');
echo $fica;
echo('</div>');
echo ('</div>');
echo ('<div class="row hidden" id="1'.$paychecknum.'">');
#### echo('<div> Deductions go here'); ######Where I need my details###
echo('</div>');
echo ('</div>');
對於指出的部分,我需要一個不同的查詢結果。可能嗎?最好的解決方案?
難道我需要另一個while循環,因爲我會從第二SQL查詢獲得的多個結果? –
答案是肯定的。我會。但現在起作用了,非常感謝。 –
是的,我打錯了代碼。 (固定)。沒問題,很高興聽到你有它的工作。 – AndrewR