You are here: Re: How to remove row from ezSQL object? « PHP Programming Language « IT news, forums, messages
Re: How to remove row from ezSQL object?

Posted by Jerry Stuckle on 02/28/07 01:46

deko wrote:
> 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... ?
>

http://us2.php.net/manual/en/control-structures.foreach.php
and
http://us2.php.net/manual/en/function.unset.php

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

 

Navigation:

[Reply to this 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

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