I am altering some code for a cart.
I am altering it so then i can have a product with sub items for products that come in different packaging sizes each with there own individual prices.
The goal of the code bellow is to determine whether or not the product is charged 'Per Item' which means there will be no sub items and all the information is stored in the table tbl_products.
OR if it is another value such as Kg's, Lb's etc.. which will indicate that their are sub items.
<?php
$pdId=$_GET['p'];// Product ID
$sql=mysql_query("SELECT * FROM tbl_product WHERE pd_id='$pdId'");
$rowProduct=mysql_fetch_array($sql); // Finds measurement type
// Check to see if product has a sub table
if($rowProduct['pd_measurement']='Per Item')
{
// Has no sub table, is there any of this product available?
if($rowProduct['pd_qty'] > 0){
echo '<tr align="left">
<td colspan="2" width="70%">
<p align="right">1 x Per Item</p>
</td>
<td width="30%">
<p> <input type="button" name="btnAddToCart" value="Add To Cart >" onClick="window.location.href=\''.$cart_url.'\'" class="addToCartButton"></p>
</td>
</tr>';
}else{
//Is no product available, echo OUT OF STOCK
************ echo '
<tr align="left">
<td colspan="2" width="70%">
<p align="right">1 x Per Item</p>
</td>
<td width="30%">
<p>OUT OF STOCK</p>
</td>
******** </tr>';
}
// Product has sub table, search it for matching parent.
}else{
$sqlsub=mysql_query("SELECT * FROM tbl_subProduct WHERE pdsub_id='$pdId'");
//Look for all sub products
while($rowSubProduct=mysql_fetch_array($sqlsub))
{
// Is there any of this sub product in stock?
if($rowSubProduct['pd_subQty']> 0){
echo '<tr align="left">
<td colspan="2" width="70%">
<p align="right">1 x '.$rowSubProduct['pd_size'].' '.$rowProduct['pd_measurement'].' Item</p>
</td>
<td width="30%">
<p> <input type="button" name="btnAddToCart" value="Add To Cart >" onClick="window.location.href=\''.$cart_url.'\'" class="addToCartButton"></p>
</td>
</tr>';
}else{
//None of this sub product in stock
echo '<tr align="left">
<td colspan="2" width="70%">
<p align="right">1 x '.$rowSubProduct['pd_size'].' '.$rowProduct['pd_measurement'].' Item</p>
</td>
<td width="30%">
<p>OUT OF STOCK</p>
</td>
</tr>';
}// End control stucture sub product check
}// End while statement
}// End Primary Control structure
?>
Problem: I find that this code displays between the marked out area (defined by *****) even when the data in the DB column 'pd_measurement' is not equal to 'Per Item'.
Is this because I have written my control structure wrong and it requires elseif and requires me to input into this code all the other options for pd_measurement rather then just 'Per Item'
Anyones help would be greatly appreciated!