Hello everybody,
I have got 2 tables on my db: Products and Productimages
I'm trying to update ordering of the images on Productimages table which are related to a product:
My Productimages table:
imageid - imagepath - productid - ordering
I reach to the update page via product id (on url: update-product-image-order/3). This update page shows only the images related to this product (in this example, it is 3)
On this page I am calling images via a "foreach" and all images have the same 'name'.
And, no matter what I tried, I couldn't make it.
My View:
How should I set up my controller and my model? I would be grateful if you could show me the way.
I have got 2 tables on my db: Products and Productimages
I'm trying to update ordering of the images on Productimages table which are related to a product:
My Productimages table:
imageid - imagepath - productid - ordering
I reach to the update page via product id (on url: update-product-image-order/3). This update page shows only the images related to this product (in this example, it is 3)
On this page I am calling images via a "foreach" and all images have the same 'name'.
And, no matter what I tried, I couldn't make it.
My View:
PHP Code:
<form role="form" method="post" action="<?php echo base_url('cp/productimageneworder'); ?>">
<?php
foreach($images as $img) { ?>
<img class="current-imgs" src="<?php echo $img->imagepath; ?>" alt="<?php echo $img->imgdata; ?>">
<input type="hidden" name="relatedphoto" value="<?php echo $img->imgid; ?>">
<select id="ordering" name="order">
<option>Choose the new order for the photo?</option>
<option value="0" <?php if($img->ordering==0){echo 'selected';}?>>0</option>
<option value="1" <?php if($img->ordering==1){echo 'selected';}?>>1</option>
<option value="2" <?php if($img->ordering==2){echo 'selected';}?>>2</option>
<option value="3" <?php if($img->ordering==3){echo 'selected';}?>>3</option>
<option value="4" <?php if($img->ordering==4){echo 'selected';}?>>4</option>
<option value="5" <?php if($img->ordering==5){echo 'selected';}?>>5</option>
</select>
<div class="clr"></div>
<?php } ?>
How should I set up my controller and my model? I would be grateful if you could show me the way.