Jump to content

check if invoice contains mobile phone


vinpkl

Recommended Posts

hi all

 

i have different categories like mobiles, cameras, gps etc.

 

then i have product_table in which products are added under those categories.

 

now i want to show a special coupon button on invoices which include mobile purchases by customers.

 

so if a invoice contains "mobile phone" then only that button should appear in front of invoice number.

 

i have

 


1) product_name in order_detail_table.

2) category_name "mobile phone" in product_table.

 

so its a huge database and i cannot change anything in it.

 

where i m stuck is how to check that invoice contains mobile phone.

 

$or_detail_qry="select * from order_detail_table where order_id = $ord_id";
$or_detail_result=mysql_query($or_detail_qry);
while($or_detail_row=mysql_fetch_array($or_detail_result))
{
$product_name=$or_detail_row['product_name'];
}


$prod_qry="select * from product_table where category_name='Mobile Phones'";
$prod_result=mysql_query($prod_qry);
while($prod_row=mysql_fetch_array($prod_result))
{			
$prod_name=$prod_row['product_name'];
}


if(($product_name == $prod_name))
{

echo "<td>". "<img src='images/special_coupon.gif' />" . "</td>";
}

 

 

the whole above code is inside a while loop which displays all the invoices result rows.

 

vineet

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/198192-check-if-invoice-contains-mobile-phone/
Share on other sites

This whole code could be probably improved, but to do what you need it would be enough to do:

$prod_qry="select * from product_table where category_name='Mobile Phones'";
$prod_result=mysql_query($prod_qry);

if(mysql_num_rows($prod_qry)>0) {      //
  $invoceContainsAMobilePhone = true;  //   This code addded
}                                                              //

while($prod_row=mysql_fetch_array($prod_result))
{         
   $prod_name=$prod_row['product_name'];
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.