[英]how to display input and output in same page?
I have only one PHP file. 我只有一个PHP文件。 but using two separate PHP tags. 但使用两个单独的PHP标签。 If I click first row in table of first PHP tag I need to display first row value in table of second PHP tag in same page. 如果单击第一个PHP标记表中的第一行,则需要在同一页面的第二个PHP标记表中显示第一行的值。 common field for two tables is order_id
The output should display beside to the first table. 两个表的公共字段是order_id
输出应显示在第一个表的旁边。
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script type="text/javascript">
$(function() {
$('.one').click(function() {
$(".slidediv").slideToggle();
});
});
</script>
</head>
<body>
<?php
session_start();
include "db.php";
$query = "select * from orders_list";
$result = mysql_query($query);
$num_rows = mysql_num_rows($result);
if($num_rows >= 1)
{
echo "<div id='showmenu' class='scroll'>";
echo "<table id='table_struct' cellspacing='0' cellpadding='1' border='1' width='400'>
<tr class='tr_class' bgcolor='#0066CC'>
<td align='center' style='font-weight:bold'> Select </td>
<td align='center' style='font-weight:bold'> order_id </td>
<td align='center' style='font-weight:bold'> customer_name </td>
<td align='center' style='font-weight:bold'> no_of_pack </td>
<td align='center' style='font-weight:bold'> price </td>
<td align='center' style='font-weight:bold'> Weight </td>
<td align='center' style='font-weight:bold'> payment mode </td>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr class='one' data-id='".$row['order_id']."'>
<td align='center'><input type='checkbox' class='case' name='case' value='1'></td>
<td align='center'>".$row['order_id']."</td>
<td align='center'>".$row['customer_name']."</td>
<td align='center'>".$row['number_of_pack']."</td>
<td align='center'>".$row['price']."</td>
<td align='center'>".$row['weight']."</td>
<td align='center'>".$row['payment']."</td>";
/*echo "<td align='center'><a href='pin.php?increment_id=".$row['increment_id']."&postcode=".$row['postcode']."&proposed_shipping=".$proposed_shipping." '>SUBMIT</a></td>";*/
echo "</tr>";
}
$order_id = $row['order_id'];
global $order_id;
echo "</table>";
echo "</div>";
}
if(!mysql_close($con))
{
echo "failed to close";
}
?>
<div>
<?php
include "db.php";
global $order_id;
$query = "select * from orders_details where order_id=$order_id";
echo $query;
$result = mysql_query($query);
$num_rows = mysql_num_rows($result);
if($num_rows >= 1)
{
echo "<div class='menu' class='scroll'>";
echo "<table id='table_struct' cellspacing='0' cellpadding='1' border='1' width='400'>
<tr class='slidediv' bgcolor='#0066CC'>
<td align='center' style='font-weight:bold'> Product </td>
<td align='center' style='font-weight:bold'> Quantity </td>
<td align='center' style='font-weight:bold'> Sku </td>
<td align='center' style='font-weight:bold'> Price </td>
<td align='center' style='font-weight:bold'> Total </td>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr class='slidediv'>
<td align='center'><input type='checkbox' class='case' name='case' value='1'></td>
<td align='center'>".$row['product']."</td>
<td align='center'>".$row['quantity']."</td>
<td align='center'>".$row['sku']."</td>
<td align='center'>".$row['price']."</td>
<td align='center'>".$row['total']."</td>";
echo "</tr>";
}
echo "</table>";
echo "</div>";
}
if(!mysql_close($con))
{
echo "failed to close";
}
?>
</body>
no need to declare $order_id global, just put your code $order_id = $row['order_id']; 无需全局声明$ order_id,只需将您的代码$ order_id = $ row ['order_id']; inside while loop and use this in your page anywhere and enjoy.. 在while循环内,并在您的页面中的任何地方使用它并享受。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.