Display accessory which match with mobile model

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vinpkl
    New Member
    • Oct 2008
    • 41

    Display accessory which match with mobile model

    hi all

    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,E7 4......" 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'


    Code:
    <?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
    }
    ?>
    i m not getting the desired results

    vineet
  • ariful alam
    New Member
    • Jan 2011
    • 185

    #2
    How many tables you have 1 or 2. if you have 2 tables like,
    1. mobile_phone
    2. phone_accessori es

    Now suppose, first table mobile_phone has the following fields
    Code:
       phone_model (contains E63, E72 any one in each row)
       phone_name  (contains the manufacturer)
       phone_image (contains the image or image path of the model)
    and the second table phone_accessori es has the following fields
    Code:
       accessories_id (contains accessories id)
       accessories_info (contains accessories information)
       accessories_supported_phones (contains phone_model like E63, E72 one or more in each row)
    then to list phone model you can use the following query
    Code:
    select phone_model from mobile_phone
    after selecting a mobile phone it shows the phone manufacturer name name a model image on the page.

    to show the accessories information on the selected phone you can use the following query
    Code:
    select accessories_info from phone_accessories where accessories_supported_phones like '%'+phone_model+','
    hope this help you.

    Comment

    • vinpkl
      New Member
      • Oct 2008
      • 41

      #3
      i alam

      i have only one table.

      vineet

      Comment

      • ariful alam
        New Member
        • Jan 2011
        • 185

        #4
        Than, can you write here the table structure?

        Comment

        Working...