(07-20-2016, 08:35 AM)davy_yg Wrote: Hello,
I try this: <?= base_url($image['src']; ?>
PHP Code:
<br><br>
<table style="padding: 10px;">
<tr>
<td><b>EDIT CAPTION</b></td>
<td><center><b>IMAGES</b></td>
<td><b>DELETE</b></center></td>
</tr>
<tr>
<td><input type="text" name="caption" value=""></td>
<td><img src="<?php echo base_url('uploads/'.<?= base_url($image['src']; ?>'); ?>" height="300" width="400"></td>
<td><button class="delete">DELETE</button></td>
</tr>
<tr>
<td><input type="text" name="caption" value=""></td>
<td><img src="<?php echo base_url('uploads/pic2.jpg'); ?>" height="300" width="400"></td>
<td><button class="delete">DELETE</button></td>
</tr>
</table>
</div>
<?php echo form_close(); ?>
<?php if (isset($success_msg)) { echo $success_msg; } ?>
</div>
And it does not read my codes.
Parse error: syntax error, unexpected '<' in C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyGiondaCI\application\views\addslideshows.php on line 112
A PHP Error was encountered
Severity: Parsing Error
Message: syntax error, unexpected '<'
Filename: views/addslideshows.php
Line Number: 112
Backtrace:
That's because you copied part of one line of my code into the wrong place within your existing code.
is a short-hand for
PHP Code:
<?php echo 'something'; ?>
and it is an error to put <?= inside a PHP tag.
The basic idea is that your controller would pass an array called $images to the view which contains a series of arrays, each of which contains the definition of the various properties of your image (caption, src, width, height).
PHP Code:
$images = [
[
'caption' => '',
'src' => 'uploads/pic1.jpg',
'height' => 300,
'width' => 400,
'id' => 1,
],
[
'caption' => '',
'src' => 'uploads/pic2.jpg',
'height' => 300,
'width' => 400,
'id' => 2,
],
];
$this->load->view('add slideshows', ['images' => $images]);
Then you could loop through $images to extract the properties of each $image into a row in your table. So, $image['src'] would return 'uploads/pic1.jpg' for your first image, 'uploads/pic2.jpg' for your second image, etc..