-3

my code is not working because it says the row is undefined i dont know what is the problem is? enter image description here

and my code is

echo '<div class="col-md-6">';
                $ImageLocation = $row['ImageLocation'];
                echo '<img alt="100%x280" style="height: 699px; width: 433px; display: block;" src="'.$ImageLocation.'" data-holder-rendered="true">';
                echo '</div>';
                echo '<div class=col-md-6>';
                echo '<form method="post" action="book.php?action=add&code='.$id.'">';     
                // echo '<img src = "'.$ImageLocation.'">';
                echo '<p class="card-text">'.$row['Description'].'</p>';
                //echo '<p class="card-text">'.$row['Price'].'</p>';
                echo '<h3>Rs. '.$row['Price'].'</h3>';
                echo '<input type="hidden" name="hidden_quantity" value="1"/>';
                echo '<input type="hidden" name="hidden_price" value="'.$row['Price'].'" />';
                echo '<input type="hidden" name="hidden_product_name" value="'.$row['ProductName'].'" />';
                echo '<input type="submit" class="btn btn-info" value="ADD TO CART">';
                echo'</form>';
                echo '</div>';
                //echo '</div>';
kaza
  • 2,317
  • 1
  • 16
  • 25

1 Answers1

0

The problem you are having is because you just do not have a $row variable set. So there's where your error comes from. You call it, but nowhere in your code you are assigning it value.

I assume that you are trying to pull your Database records, which should be associated to your $row.

I also assume that you are trying to fetch the associative content from the database, since it is setup as $row['COLUMN_NAME'];. I do not see the code before you call the $row variables, but take a look below.

So to fix your problem look at this example example:

while ($row = $result->fetch_assoc()) {
    echo $row["ImageLocation"];
    //...
}

If you are a procedural programmer, look at this one:

while ($row = mysqli_fetch_assoc($result)) {
    echo $row["ImageLocation"];
    //...
}

For the complete set code look under PHP's manual here. The documentation is good, and it will explain what you need to be doing.

Sam
  • 2,856
  • 3
  • 18
  • 29