从表格中,我获取$ rows [' colorVariants'];但它的价值我变得像: -
[JEADV9Q23ESG25HY,JEADV9Q2NFRNYV5Q,JEADV9Q2PNBTXGNX,JEADV9Q2XKWPXWSX,JEADY8ABWH9XNF4B,JEADZWEBDHWRJ2NQ,JEADZWEBRWZ4B4VS,JEADZWEBXDCGSYCF,JEAEYYX95YYC4DRA]
然后我使用substr删除方括号。
爆炸这个值,并再次需要将它提取到相同的产品相同的表格,但我没有得到任何结果。
<?php
$table = table1; // Table Name
$mysqli = mysqli connection // Mysqli Connection here
$result = $mysqli->query( "SELECT * FROM $table_name WHERE `id` = '$q' ");
while ( $rows = $result->fetch_assoc() ) {
$rows['colorVariants'] = [JEADV9Q23ESG25HY,JEADV9Q2NFRNYV5Q,JEADV9Q2PNBTXGNX,JEADV9Q2XKWPXWSX,JEADY8ABWH9XNF4B,JEADZWEBDHWRJ2NQ,JEADZWEBRWZ4B4VS,JEADZWEBXDCGSYCF,JEAEYYX95YYC4DRA] // Result Copy Sample
// substr using for remove square bracket
$colorVariants = substr($rows['colorVariants'], 1);
$newColorVariants = substr($colorVariants, 0, '-1');
$finalColorVariants = explode(',', $newColorVariants);
}
?>
<?php
for($i = 0; $i < count($finalColorVariants); $i++) {
$color = $finalColorVariants[$i];
$color = $mysqli->real_escape_string($color);
$colorVariants = $mysqli->query( "SELECT id,store,title,imageUrlStr,mrp,price,productBrand FROM $table_name WHERE `productId` = '".$color."' ");
if ($colorVariants) {
while ($rows = $colorVariants->fetch_assoc()) {
$id1 = $rows['id'];
$store1 = $rows['store'];
$title1 = $rows['title'];
$imageUrlStr1 = $rows['imageUrlStr'];
$mrp1 = $rows['mrp'];
$price1 = $rows['price'];
$productBrand1 = $rows['productBrand'];
}
?>
<div class="cloth-inner-similar-box">
<div class="cloth-inner-similar-boxin">
<a href="clothing?q=<?php echo $id1; ?>"><img src="<?php echo $imageUrlStr1; ?>" /></a>
</div>
<div class="cloth-inner-similar-boxin-offer">
<div class="cloth-inner-similar-boxin-offer-in">
<p>30% OFF</p>
</div>
</div>
<div class="cloth-inner-similar-boxin-head">
<a href="clothing?q=<?php echo $id1; ?>"><?php echo $title1; ?></a>
</div>
<div class="cloth-inner-similar-price border-solid-bottom border-solid-top">
<a href="clothing?q=<?php echo $id1; ?>">Best Buy @ <?php echo $price1; ?>/-</a><a href="<?php echo $id1; ?>" class="href"><?php echo $productBrand1; ?></a>
</div>
</div>
<?php
} }
$mysqli->close();
?>