In the example below (btw, thanks so much for this class and the details!), how would I make a looping section.
I want to include a bunch of images in each $item and keep overwriting the variables...
ie:
<item>
<title>Title</title>
<link>link url</link>
<images>
<image>
<title>image title</title>
<url>imageurl</ul>
</image>
<image>
<title>image title</title>
<url>imageurl</ul>
</image>
<image>
<title>image title</title>
<url>imageurl</ul>
</image>
</images>
</item>
When I use the code below and the class, I only get one image (the last one from my while sql query results)
When I make the array key->values unique by adding a counter (eg: key1->value1,key2->value2 etc) I get all my images under one <image>array data</image> instead of multiple <image>stuff from first record</image><image>stuff from second record</image> etc...
Here is what I have done... perhaps you can help me with this concept.. I am not sure if XMLWriter supports what I am trying to do...
PHP Code:
if (isset($array['images']))
{
$this->startElement('media');
$this->startElement('image');
foreach ($array['images'] as $key => $value)
{
$this->writeElement($key, $value);
}
$this->endElement();
$this->endElement();
}
And to set the array in my code I am doing:
PHP Code:
if(mysql_num_rows($images))
{
$item['images'] = array();
$image_count = 1;
while($image_row = mysql_fetch_assoc($images))
{
$item['images']['image_'.$image_count.'_seq'] = $image_row['display_order'];
$item['images']['image_'.$image_count.'_filename'] = $image_row['full_filename'];
$image_count ++;
}
}
So I am close to what I needed but not all the way...
Ideas, gurus?