vinpkl Posted April 11, 2010 Share Posted April 11, 2010 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 Quote Link to comment Share on other sites More sharing options...
Mchl Posted April 11, 2010 Share Posted April 11, 2010 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']; } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.