我有兩個表格,它們使用一個稱爲invoice_no的公共列相互關聯。我想是這樣的: -使用jquery顯示/隱藏div值
要在第一喜歡 - >image 1
顯示從一個表中的數據,然後將數據顯示像這樣從第二個表當用戶點擊查看按鈕喜歡 - >image 2
我如何可以切換從第二表中的數據上的按鈕來查看的點擊在表中的每一行,而不是讓他們一下子,通過使用jQuery ..
這裏是我的代碼,我一直在使用一次查看所有數據: -
<?php
$mysqli= new mysqli("localhost","root","","store_records");
if($mysqli->connect_error)
die("Database connection failed ".$mysqli->connect_error);
$query_details = "select DATE_FORMAT(date, '%d-%m-%Y') as date, ID, invoice_no, balance, sub_total, vat_tax, grand_total from bill_details ORDER BY DATE_FORMAT(date, '%m-%d-%Y') DESC";
$result_details = $mysqli->query($query_details);
echo"<table id='products_table' border='1'>";
echo "<tr><th>Date</th><th>Invoice No</th><th>Balance</th><th>Sub Total</th><th>ADD V.A.T Tax</th><th>Grand Total</th></tr>";
while($row_details = $result_details->fetch_assoc())
{
echo "<tr><td>".$row_details['date']."</td><td>".$row_details['invoice_no']."</td><td>".$row_details['balance']."</td><td>".$row_details['sub_total']."</td><td>".$row_details['vat_tax']."</td><td>".$row_details['grand_total']."</td><td><input type='button' id='viewdetails' value='View'></td></tr>";
$query_records = "select * from bill_records where invoice_no='".$row_details['invoice_no']."'";
$result_records = $mysqli->query($query_records);
echo "<td colspan='15'>";
echo "<table border='1' width='100%'>";
echo "<tr><th>Item Name</th><th>Quantity</th><th>Pack</th><th>Batch</th><th>Expiry</th><th>M.R.P</th><th>Rate</th><th>VAT</th><th>DIS.</th><th>Amount</th></tr>";
while($row_records = $result_records->fetch_assoc())
{
echo "<tr><td>".$row_records['item_name']."</td><td>".$row_records['qty']."</td><td>".$row_records['pack']."</td><td>".$row_records['batch']."</td><td>".$row_records['expiry']."</td><td>".$row_records['mrp']."</td><td>".$row_records['rate']."</td><td>".$row_records['vat']."</td><td>".$row_records['discount']."</td><td>".$row_records['amount']."</td></tr>";
}
echo "</table>";
echo "</td>";
echo"</tr>";
}
echo "</table>";
?>
感謝你們的幫助:)
你現在有什麼問題?你有什麼嘗試? –
我試圖把第二個表的值顯示在這個$(document).ready(function(){(#product_details []「)(); \t $(」#viewdetails 「).click(function(){ \t $(this).prev(」#product_details []「)toggle();但它只適用於一行.. – Jyotishmoy