php - id isn'tcarrying forward the associated ID image that was selected -


i trying selected product id's image move forward checkout page, of now, carries forward first product image have listed on main products page.

i have of products listed in foreach loop this..

<?php    // loop display products foreach($products $id => $product) { ?>     <div class="item">         <div class="productpiccontainer">             <?php echo "<img class='productpagesizedimg' src='productpics/".$product['img'] ."' alt='product pic'>"; ?>         </div>                <p><?php echo "<a href='./viewproduct.php?view_product=$id'>" . $product['product_name'] . "</a>"; ?></p>         <p><?php echo "$" . $product['price']; ?></p>     </div> <?php } ?> 

i able correct product image when select on product. takes me page called viewproducts.php. works great on page. pulling product id , image this..

<?php $result = mysqli_query($con,"select * products product_id =".$_get['view_product']); if($row = mysqli_fetch_array($result)) {     $products[$row['product_id']] = $row;     echo "<img class='sizedimg' src='productpics/".$row['img'] ."' alt='product pic'>"; } ?> 

something noticed though have code on viewproducts.php page..

// view product if(isset($_get['view_product'])) {     $product_id = $_get['view_product']; 

and don't have in checkout page. when try add code above checkout breaks everything. have more php code in checkout page , need code image part, tried surrounding image code this..

<?php  // view product if(isset($_get['view_product'])) {     $product_id = $_get['view_product'];     $result = mysqli_query($con,"select * products product_id =".$_get['view_product']);     if($row = mysqli_fetch_array($result)) {         $products[$row['product_id']] = $row;          if($row['image'] == ""){             echo "<img class='sizedimg' src='productpics/".$row['img'] ."' alt='product pic'>";         }         echo "<br><br><br><br>";     } } ?> 

with code, blank spot. image doesn't show @ all. there i'm not doing right?

update:

<?php if(isset($_get['view_product'])) {     $product_id = $_get['view_product']; } $result = mysqli_query($con,"select * products product_id =".$_get['view_product']); if($row = mysqli_fetch_array($result)) {     $products[$row['product_id']] = $row;      echo "<img class='sizedimg' src='productpics/".$row['img'] ."' alt='product pic'>";      echo "<br><br><br><br>"; } ?> 

error:

warning: mysqli_fetch_array() expects parameter 1 mysqli_result, boolean given in /home4/pfarley1/public_html/checkout.php on line 474

for line

if($row = mysqli_fetch_array($result)) { 

update:

when have code this, image show up, first product in database on , on again amount of products have in cart...

<?php $result = mysqli_query($con,"select * products"); if($row = mysqli_fetch_array($result)) {     $products[$row['product_id']] = $row;      if($row['image'] == ""){         echo "<img class='sizedimg' src='/productpics/".$row['img']."' alt='product picture'>";     }   } echo "<br><br><br><br>"; ?> 

if($row['image'] == ""){     echo "<img class='sizedimg' src='productpics/".$row['img'] ."' alt='product pic'>"; } 

clear 1 thing in code

$row["image"] 

and

$row["img"] 

both same or different. means miss typed or both columns exists in database , value these columns have?


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -