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
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'];
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.