Jump to content

dogguy2010

New Members
  • Posts

    2
  • Joined

  • Last visited

Posts posted by dogguy2010

  1. Can some one please explain to me why the following code echoes the results twice?

     

    <?php
    
    
        //includes:
        include('connections.php');
        include('my_functions.php');
    
    
        //select last record from coupoons table and set applicable variables
        $query = mysql_query("SELECT * FROM coupons ORDER BY coupon_id DESC LIMIT 1") or die(mysql_error());
            while($rows = mysql_fetch_array($query))
            {
                $coupon_id = $rows['coupon_id'];
                $barcode = $rows['barcode'];
                $company_prefix = $rows['company_prefix'];
                $family_code = $rows['primary_purch_family_code'];
    echo 'coupon_id ', $coupon_id,'<br>','<br>';
            }     
    
    
    $query1 = mysql_query("SELECT manufacturers.company_prefix, family_codes.family_code, brands.brand, manufacturers.mfg
    FROM (manufacturers INNER JOIN brands ON manufacturers.`company_prefix` = brands.`company_prefix`) INNER JOIN family_codes ON brands.`brand_id` = family_codes.`brand_id`
    WHERE (((manufacturers.company_prefix)=$company_prefix) AND ((family_codes.family_code)=$family_code))");
            while ($rows = mysql_fetch_array($query1))
            {
                $mfg = $rows['mfg'];
                $brand = $rows['brand'];
                $family_code = $rows['family_code'];
    echo $mfg,$brand,$family_code,'<br>' ;            
            }
    ?>
     
    The results that I want:
     
    Keebler100 Calorie Right Bites390
    Sunshine100 Calorie Right Bites390
     
    The results I am getting:
     
    Keebler100 Calorie Right Bites390
    Sunshine100 Calorie Right Bites390
    Keebler100 Calorie Right Bites390
    Sunshine100 Calorie Right Bites390
     
    I am new to this and am probably missing something very simple, but I can not figure it out.
    Please help.
  2. I am very new to all of this and I am not sure if this is your problem or not, but maybe.

     

    Shouldn't your query look like:

     

    $query sprintf("INSERT INTO ......  ");

     

    yours is currently:

     

    $query sprintf("INSERT INTO ......  );

     

    I think you are missing the set of quotation marks at the end of the query.

    I hope that helps.

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