我有2个数据库表1是用户表,其他是market_offer表。我想用户显示优惠。就像用户发送报价时只更新当前报价一样,所有报价必须在更多报价页面上,该页面应该只包含特定的用户数据。
这是一段代码:
//Market_offer.php where I have displayed offers according to users_id
<div class="panel panel-body">
<?php
$output = '';
$query = "SELECT u.*,t.*
FROM users u
JOIN add_offer t ON t.user_id = u.id
GROUP BY u.id, u.name ORDER BY t.id DESC";
$res = mysqli_query($connect, $query);
while($row = mysqli_fetch_array($res))
{
$output .= '<div class="col-md-3 col-sm-4 col-lg-6">';
$output .= '<div class="panel panel-default">';
$output .= '<div class="panel-heading">'.preg_replace("/(?!^)./", "*", $row["name"]).'</div>';
$output .= '<div class="panel-body">';
$output .= '<div style="padding:3px;float:left;font-weight:bold;">'.$row["part_no"].'</div>';
$output .= '<div style="padding:3px;float:left;">'.$row["make"].'</div>';
$output .= '<div style="padding:3px;float:left;">'.$row["date_code"].'</div>';
$output .= '<div style="padding:3px;float:left;">'.$row["qty"].'</div>';
$output .= '<br>';
$output .= '<div style="float:left;font-size:9px;">';
$output .= '<a href="user.php?id='.$row["user_id"].'">More Offers>>';
$output .= '</a>';
$output .= '</div>';
$output .= '<div style="float:right;font-size:9px;">'.date('d-m-Y H:i:s',strtotime($row["time"])).'</div>';
$output .= '</div>';
$output .= '</div>';
$output .= '</div>';
}
echo $output;
?>
</div>
//user.php where I want a particular users offers only to be displayed here.
<div class="panel-body" style="padding: 0px;padding-left: 5px;border-bottom: 1px solid #66512c;">
<?php
if(isset($_GET['user_id'])) {
$user_id = $_GET['user_id'];
$res=mysqli_query( $connect,"SELECT * FROM add_offer WHERE id=$user_id");
while($row = mysqli_fetch_array($res))
{
?>
<div class="col-md-3 col-sm-4 col-lg-6">
<div class="panel panel-default">
<div class="panel-body">
<div style="padding:3px;float:left;font-weight:bold;">
<?php echo $row["part_no"];?>
</div>
<div style="padding:3px;float:left;">
<?php echo $row["make"]; ?>
</div>
<div style="padding:3px;float:left;">
<?php echo $row["date_code"]; ?>
</div>
<div style="padding:3px;float:left;">
<?php echo $row["qty"]; ?>
</div>
<br>
<div style="float:right;font-size:9px;">
<?php echo date('d-m-Y H:i:s',strtotime($row["time"])); ?>
</div>
</div>
</div>
</div>
<?php
}
}
?>
</div>