Currently working on a bespoke ecommerce application using Codeigniter.
I have a products table with a list of products and a news table with a list of news items.
For example, the news items are displayed dynamically using a foreach loop, i would like to add images to the news items dynamically though some news items have 2 or 3 images.
I understand i could use an image_id to match the news item/product to an image within a table (url links of images), but what about multiple images, is it a fie
ld type? a different database setup?
News.php
<a href="news/<?php echo $news_item['slug'] ?>
<h2><?php echo $news_item['title'] ?></h2>
</a>
<div id="main">
<?php echo $news_item['text'] ?>
</div>
<a href="news/<?php echo $news_item['image'] ?>">
<?php endforeach ?>
Perhaps you could serialize an array of images (containing urls of images) for each news into a JSON string and input it into the image field in your news table.
See it here: Serialize function
Will that work for you?