Looping file |
Hello,
Can anyone help me printing all the files that I have in uploads/ ? to the screen. Each pictures must be printed in each row. views/slideshows.php PHP Code: <table style="padding: 10px;"> How?
" If I looks more intelligence please increase my reputation."
Maybe a foreach loop
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
PHP Code: <?= form_open(); ?>
Hello,
I try this: <?= base_url($image['src']; ?> PHP Code: <br><br> 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: I revise it into this: Line 112: is <td><img src="<?php echo base_url('uploads/'.<?= base_url($image['src']; ?>); ?>" height="300" width="400"></td> PHP Code: <br><br>
" If I looks more intelligence please increase my reputation."
This will never work.
You can't start php code without closing the previous php code block. Another mistake is to include base_url() twice in one image source path. I think your code should be: PHP Code: <td><img src="<?= base_url() . 'uploads/' . $image['src'];?>" height="300" width="400" /></td> (07-20-2016, 08:35 AM)davy_yg Wrote: Hello, That's because you copied part of one line of my code into the wrong place within your existing code. PHP Code: <?= 'something'; ?> 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 = [ 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..
07-20-2016, 09:37 PM
(This post was last modified: 07-21-2016, 12:27 AM by davy_yg. Edit Reason: slideshow )
This is what I try to print all gallery in rows. Can somebody help me fix this error message? Thanks in advance.
Parse error: syntax error, unexpected ';' in C:\Program Files (x86)\EasyPHP-Devserver-16.1\eds-www\CompanyGiondaCI\application\views\addslideshows.php on line 114 A PHP Error was encountered Severity: Parsing Error Message: syntax error, unexpected ';' Filename: views/addslideshows.php Line Number: 114 Backtrace: Line 114: <td><img src="<?php echo base_url('uploads/'.base_url($images_item['src']; )); ?>" height="300" width="400"></td> views/addslideshows.php PHP Code: <?php foreach ($images as $images_item): ?> cpages/addslideshows.php PHP Code: public function addslideshows() {
" If I looks more intelligence please increase my reputation."
Seriously, you cannot see what might be wrong with this?
PHP Code: <?php echo base_url('uploads/'.base_url($images_item['src']; )); ?> And MWhitney already took the time to refer to this exact problem, reread his post or reread the documents for base_url.
Might as well talk to a wall!
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
(07-20-2016, 09:37 PM)davy_yg Wrote: This is what I try to print all gallery in rows. Can somebody help me fix this error message? Thanks in advance. Despite my better judgment, I'm going to attempt to help you here. A semicolon ( indicates the end of a command in programming languages like PHP, C, JavaScript, etc. If you end a command with a semicolon before you include all of the necessary components of that command, you will get the message "syntax error, unexpected ';'". In this case, you're getting the error because you've called base_url() twice, but haven't closed the parentheses for either call before terminating the command. It would appear that you need to find some PHP tutorials in addition to some CodeIgniter tutorials, and pay a little more attention to the code you're writing as well as the error messages you're receiving. You might even want to spring for a book if you're going to be doing this a while. |
Welcome Guest, Not a member yet? Register Sign In |