Jump to content

Recommended Posts

I'm using a database table full of items that have different categories assigned to them sort of like so..

 

values are id, category, description, price

 

INSERT INTO `dw_items` VALUES (18, 'wedding_aisle', 'Palm Frond', 50);
INSERT INTO `dw_items` VALUES (19, 'wedding_aisle', 'Conch Shell', 75);
INSERT INTO `dw_items` VALUES (20, 'wedding_aisle', 'Tropical Flowers', 275);

INSERT INTO `dw_items` VALUES (21, 'wedding_circle_of_love', 'Palm Leaves', 195);
INSERT INTO `dw_items` VALUES (22, 'wedding_circle_of_love', 'Conch Shells', 75);
INSERT INTO `dw_items` VALUES (23, 'wedding_circle_of_love', 'Palm Leaves and Conch Shells', 95);

INSERT INTO `dw_items` VALUES (24, 'wedding_arch', 'Palm Fronds and Tropical Flowers', 225);
INSERT INTO `dw_items` VALUES (25, 'wedding_arch', 'Rustic Arch', 395);
INSERT INTO `dw_items` VALUES (26, 'wedding_arch', 'Rustic Arch decorated with Tulle and Flowers', 495);

 

Is there a way to print out the array and split each category into its own table?? I'm trying to figure this out because right now I have to run a separate query for each category in order to get them into their own tables..

Link to comment
https://forums.phpfreaks.com/topic/120803-how-to-use-array-differences/
Share on other sites

The array is quite large (115 items) so I'll just post some of it:

 

Array
(
    [0] => 1
    [item_id] => 1
    [1] => wedding_packages
    [item_category] => wedding_packages
    [2] => Wedding Package Slice of Paradise
    [item_description] => Wedding Package Slice of Paradise
    [3] => 845
    [item_price] => 845
)
Array
(
    [0] => 2
    [item_id] => 2
    [1] => wedding_packages
    [item_category] => wedding_packages
    [2] => Wedding Package Barefoot Bliss
    [item_description] => Wedding Package Barefoot Bliss
    [3] => 1245
    [item_price] => 1245
)
Array
(
    [0] => 3
    [item_id] => 3
    [1] => floral_arrangements
    [item_category] => floral_arrangements
    [2] => Bridesmaid and Mother of the Bride Bouquet Tropical Large
    [item_description] => Bridesmaid and Mother of the Bride Bouquet Tropical Large
    [3] => 75
    [item_price] => 75
)
Array
(
    [0] => 4
    [item_id] => 4
    [1] => floral_arrangements
    [item_category] => floral_arrangements
    [2] => Corsage Tropical
    [item_description] => Corsage Tropical
    [3] => 25
    [item_price] => 25
)

 

Let me know if that is enough.. That is 4 items from 2 categories, which Im looking to try to output into 2 tables.. Each category having it's own table..

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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