Reply to Re: How to remove row from ezSQL object?

Your name:

Reply:


Posted by deko on 02/27/07 23:56

This is a better example:

$category = $db->get_results("SELECT cat_id, cat_name ... FROM Table_A");
$itemdata = $db->get_results("SELECT category_id, item_name ... FROM Table_B");

$i =0
foreach ($category as $cat_item)
{
echo $cat_item->cat_name;
foreach ($itemdata as $item_datum)
{
if ($item_datum->category_id == $cat_item->cat_id)
{
echo '--'.$item_datum->item_name;
array_splice($itemdata, $item_data[$i - 1], 1);
//the next category will not contain the matched item
//since items can only belong to one category
//so we can remove matched item_datum from itemdata
//and reduce iterations next time we are in this loop
}
$i++;
}
}

Apples (cat_name)
-- red (item_name)
-- green
-- small
-- large
Oranges
-- ripe
-- rotten

$itemdata is an object, not an array, which is why I need to index it with $i
(object items do not have numeric keys). So $i indexes the items in the
$itemdata object, allowing me to use array_splice() on an object... ?

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация