1

The images are stored inside separate folders.

Both the folders and the images are saved in the database. In my gallery page, they are shown from the database in two steps.

  1. The folders are retrieved from the db and listed in the gallery page
  2. while on-click of a folder, the images are listed.

So far, I have passed the data from the database to the view. The following is my controller code.

function image_show() {
    $this->load->model('gallery_model');
    $data['folder_info'] = $this->gallery_model->get_folder_names();
}

and my view code is as follows:

<?php foreach($folder_info as $show){ ?>
<a class="glyphicon glyphicon-folder-close" style="font-size: 100px;" aria-hidden="true" onclick="imageslide(' .$show['folder_name'] .');" ></a>    
<?php } ?>

From the above code, the folders are listed in the gallery page. I am struck while trying to pass the $show['folder_name'] from the php foreach loop so that I can generate a image slider. My script is

function imageslide(name) {
    alert(name);
}

The error shown to me is

gallery:194 Uncaught SyntaxError: missing ) after argument list

Kindly help me out!

1 Answer 1

2

You should pass the $show['folder_name'] variable inside a php block, i.e.:

<?php foreach($folder_info as $show){ ?>
<a class="glyphicon glyphicon-folder-close" style="font-size: 100px;" aria-hidden="true" onclick="imageslide('<?php echo $show['folder_name'] ?>');" ></a>
<?php } ?>
Sign up to request clarification or add additional context in comments.

1 Comment

How should I pass the $show['folder_name'] to the data in ajax call inside the <script> after the onclick function..?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.