Jump to content

PHP and Mysql, i get duplicate values even if there is no duplicates on db


bakhtn

Recommended Posts

while ( $categories = $category_result -> fetch_assoc() )

{

$menu_sql = "select * from menu where category_id = {$categories['category_id']}";

 

$menu_result = $handle -> query( $menu_sql );

 

$category2 = strtoupper($categories['category']);

 

echo '<h3 id="' . $category2 . '">' . $category2 . '</h3>';

 

 

while ($menu = $menu_result -> fetch_assoc())

{

 

echo $menu['item_name'] . ' ';

 

 

$size_sql = "select distinct size from size where category_id = {$categories['category_id']} order by size desc";

$size_result = $handle -> query( $size_sql );

 

while ($size = $size_result -> fetch_row())

    {

echo $size[0] . ' ';

}

 

//get base type from base_type table for the pizza category

$type_sql = "select type from base_type where category_id = {$categories['category_id']}";

$type_result = $handle -> query( $type_sql );

 

while ($type = $type_result -> fetch_row())

    {

echo $type[0] . ' ';

}

 

 

//get price for each item from menu if it is not null

$price_sql = "select price from menu where item_name = '{$menu['item_name']}'";

$price_result = $handle -> query( $price_sql );

 

while ($price = $price_result -> fetch_row())

    {

echo $price[0] . ' ';

 

if( is_null( $price[0] ) )

{

//get price from size table if price is null in menu table;

 

                    //$categories = $category_result -> data_seek(0);    

 

$size = "double";

$category_id = $categories['category_id'];

$item_id = $menu['item_id'];

$type = 'deep';

 

echo $menu['item_id'];

           

 

$price_size_sql = "select price from size where size = '$size' and category_id = $category_id and item_id = $item_id";

$price_size_result = $handle -> query( $price_size_sql );

 

while ($price_size = $price_size_result -> fetch_assoc())

{

 

echo " {$price_size['price']} ";

 

}

}

 

}

 

echo '<br />';

 

}

    echo '<br />';

}

 

 

I get duplicate vakues for $category_id = $categories['category_id'];

$item_id = $menu['item_id'];

 

dont know whats wrong it works for pizzas but not burgers, please help me.

 

Archived

This topic is now archived and is closed to further replies.

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