我有3张桌子,1)。移动,2)。 store1,3)。商店2 从表“移动”获取然后我们从表中收到4行记录。 然后我将此行提取到store1和store2以获取其他详细信息。
请建议我需要做什么。
<?php
$mysqli = new mysqli("host" , "user" , "pass" , "database");
$result = $mysqli->query( "SELECT * FROM mobile WHERE live= '1' ") ;
while ( $rows = $result->fetch_assoc() ) {
$store = $rows["store"];
$productId = $rows["productId"];
$store2 = $rows["store2"];
$productId2 = $rows["productId2"];
php?>
<?php
$result = $mysqli->query( "SELECT * FROM $store where productId='$productId' ") ;
while ( $rows = $result->fetch_assoc() ) {
$title = $rows["title"];
$productImage = explode (",", $rows['imageUrlStr']);
$mrpPrice = explode (",", $rows['mrp']);
$offerPrice = explode (",", $rows['price']);
}
$result = $mysqli->query( "SELECT * FROM $store2 where productId= '$productId2' ") ;
while ( $rows = $result->fetch_assoc() ) {
$title2 = $rows["title"];
$productImage2 = explode (",", $rows['imageUrlStr']);
$mrpPrice2 = explode (",", $rows['mrp']);
$offerPrice2 = explode (",", $rows['price']);
} ?>
<li class="mobile-box als-item">
<div class="mobile-box-top">
<div class="mobile-box-top-img"><img src="<?php echo $productImage[5]; ?>" alt="" title="" /></div>
<div class="mobile-box-top-txt"><?php echo $title; ?></div>
<div class="mobile-box-top-tag"><i class="fa fa-inr"></i> <?php echo $offerPrice[0]; ?></div>
</div>
<div class="mobile-box-bottom border-bottom">
<div class="mobile-box-bottom-img"><img src="<?php echo $productImage2[5]; ?>" alt="" title="" /></div>
<div class="mobile-box-bottom-txt"><?php echo $title2; ?></div>
<div class="mobile-box-bottom-tag"><i class="fa fa-inr"></i> <?php echo $offerPrice2[0]; ?></div>
</div>
<div class="mobile-box-button"><a href="">Compare Now</a></div>
</li>
答案 0 :(得分:0)
你必须这样做
第1步:尝试获取这样的查询,因为您正在获取结果中的数据
所以试着这样做
$result1 = $mysqli->query( "SELECT * FROM $store where productId= $result.productId ") ;
表二相同