i have "product table" in which i have 2 categories.
1) Mobile Phone
2) Mobile Phone Accessories which consists of many "Phone Covers"
Some Phone covers are compatible with 8-10 mobiles.
For Mobile phone category, the The "model" field contains single value like "E71" or "E72".
But For Accessories category, The "model" field contains value like "E71,E72,E73,E74......" all together separated with comma.
if i m on e72 mobile phone page then i want to show accessories whose 'model' field have value 'e72'
Expand|Select|Wrap|Line Numbers
- <?php
- /* query to select all models from accessories category from product table */
- $qry_model="select * from product_table where category_id=4";
- $qry_model_result=mysql_query($qry_model);
- while($qry_model_row=mysql_fetch_array($qry_model_result))
- {
- $desc_model_all = $qry_model_row['model'];
- $desc_model_all = explode(',', $desc_model_all);
- foreach ($desc_model_all as $value)
- {
- echo $value; /* this outputs as E73E72 */
- }
- }
- $mobile_model = $row['model'];
- if($value == $mobile_model)
- {
- $qryc="select * from product_table where model = '$value' and category_id=4";
- $resultc = mysql_query($qryc);
- if(mysql_num_rows($resultc)>0)
- {
- // product detail is displayed here
- }
- ?>
vineet