PHP Codeigniter Base_URL - php

Please help.
Almost finish my final project..
Somehow the gallery meets an error for displaying it's pictures, I thought it's because the base_url
<?php
//FOLDER GALLERY-PART
$dirname = "./assets/images/gallery/";
$images = glob($dirname."*.jpg");
array_multisort(array_map('filemtime', $images), SORT_NUMERIC, SORT_DESC, $images);
foreach($images as $image) {
echo //'<img src="'.$image.'" /><br />'; -- Ini cth untuk tampilkan semua gambar (dlm Garis lurus)
"<div class='col-xs-6 col-sm-4 col-md-3 portfolio-item logos'>
<div class='portfolio-wrapper'>
<div class='portfolio-single'>
<div class='portfolio-thumb'>
<img src='.$image.' class='img-responsive' alt=''>
</div>
<form id='imgtitle' class='kart' action='" . base_url() . "gallery/delete' method='post'>
<div class='portfolio-view'>
<ul class='nav nav-pills'>
<li><a href='#'><i class='fa fa-link'></i></a></li>
<li><a href='.$image.' data-lightbox='example-set'><i class='fa fa-eye'></i></a></li>
<li><a href='#'><i class='fa fa-heart'></i></a></li>
</ul>
</div>
</form>
</div>
<div class='portfolio-info'>
<form id='imgtitle' class='kart' action='" . base_url() . "gallery/delete' method='post'>
<input type = 'hidden' name='delete_file' value='$image' />";?>
<?php if($_SESSION['admin']==1):?>
<button type = 'submit' class='btn btn-danger'><i class='delete fa fa-trash fa-3x'></i></button>
<?php endif; ?>
<?="</form>
</div>
</div>
</div>";
}
?>
How to put base_url on
$dirname
Or any other suggestion?

try this:
<img src='".base_url()$image."' class='img-responsive' alt=''>

$dirname = "./assets/images/gallery/";
$images = glob($dirname."*.jpg");`
echo '<img src="'.$baseurl/$image.'" /><br />'; ?>

Related

echo inside div inside echo [duplicate]

This question already has answers here:
display div inside php using echo
(2 answers)
Closed 4 months ago.
I'm trying to use echo in this code
<?php
require 'connect.php';
$query = mysqli_query($conn, "SELECT * FROM `videos`") or die(mysqli_error());
while($fetch = mysqli_fetch_array($query)){
$id= $fetch['id'];
?>
<?php echo "
<li class='col-lg-4 col-md-6 col-dm-12'>
<div class='da-card box-shadow'>
<div class='da-card-photo'>
<img src=' echo $fetch['video_name']' alt=''>
<div class='da-overlay'>
<div class='da-social'>
<h4 class='mb-10 color-white pd-20'></h4>
<ul class='clearfix'>
<li>
<a href='' data-fancybox='images'><i class='fa fa-picture-o'></i></a>
</li>
<li>
<a href='#'><i class='fa fa-link'></i></a>
</li>
</ul>
</div>
</div>
</div>
</div>
</li>
"; ?>
<?php
}
?>
I'm getting this error Parse error: syntax error, unexpected string content "", expecting "-" or identifier or variable or number in C:\xampp\htdocs\desk\gallery.php on line 572
Why this error?
.................................................................
You can escape the string and concatenate the variable in the place your hoping to have it like this:
<img src='". $fetch['video_name'] ."' alt=''>
<?php
require 'connect.php';
$query = mysqli_query($conn, "SELECT * FROM `videos`") or die(mysqli_error());
while($fetch = mysqli_fetch_array($query)){
$id= $fetch['id'];
?>
<?php echo "
<li class='col-lg-4 col-md-6 col-dm-12'>
<div class='da-card box-shadow'>
<div class='da-card-photo'>
<img src='". $fetch['video_name'] ."' alt=''>
<div class='da-overlay'>
<div class='da-social'>
<h4 class='mb-10 color-white pd-20'></h4>
<ul class='clearfix'>
<li>
<a href='' data-fancybox='images'><i class='fa fa-picture-o'></i></a>
</li>
<li>
<a href='#'><i class='fa fa-link'></i></a>
</li>
</ul>
</div>
</div>
</div>
</div>
</li>
"; ?>
<?php
}
?>
You can't use echo inside an echo or should I say string statement.
What you have to do is variable substitution like:
echo 'This is my variable '.$x.'.';
Or...
echo "This is my variable $x.";
In your code:
<?php
require 'connect.php';
$query = mysqli_query($conn, "SELECT * FROM `videos`") or die(mysqli_error());
while($fetch = mysqli_fetch_array($query)){
$id= $fetch['id'];
$video_name = $fetch['video_name'];
?>
<?php echo "
<li class='col-lg-4 col-md-6 col-dm-12'>
<div class='da-card box-shadow'>
<div class='da-card-photo'>
<img src='$video_name' alt=''>
<div class='da-overlay'>
<div class='da-social'>
<h4 class='mb-10 color-white pd-20'></h4>
<ul class='clearfix'>
<li>
<a href='' data-fancybox='images'><i class='fa fa-picture-o'></i></a>
</li>
<li>
<a href='#'><i class='fa fa-link'></i></a>
</li>
</ul>
</div>
</div>
</div>
</div>
</li>
"; ?>
<?php
}
?>
Also you can ditch the <?php ?>:
<?php
require 'connect.php';
$query = mysqli_query($conn, "SELECT * FROM `videos`") or die(mysqli_error());
while($fetch = mysqli_fetch_array($query)) {
$id = $fetch['id'];
$video_name = $fetch['video_name'];
echo "
<li class='col-lg-4 col-md-6 col-dm-12'>
<div class='da-card box-shadow'>
<div class='da-card-photo'>
<img src='$video_name' alt=''>
<div class='da-overlay'>
<div class='da-social'>
<h4 class='mb-10 color-white pd-20'></h4>
<ul class='clearfix'>
<li>
<a href='' data-fancybox='images'><i class='fa fa-picture-o'></i></a>
</li>
<li>
<a href='#'><i class='fa fa-link'></i></a>
</li>
</ul>
</div>
</div>
</div>
</div>
</li>
";
}

getting error on uploading multiple images using codeigniter

when uploading multiple images iam getting an error that the value of table is getting null while displaying..
here is my controler..
public function add_images()
{
$data['active_mn']='add_images';
$this->form_validation->set_rules('title','title','required');
$this->form_validation->set_rules('parentname','parent category','required');
$this->form_validation->set_rules('subname','sub category','required');
$this->form_validation->set_rules('code','code','required');
$this->form_validation->set_rules('description','Description','required');
$this->form_validation->set_rules('size','Size','required');
if($this->form_validation->run()==TRUE)
{
$image=array_values($this->session->userdata('image'));
$images=json_encode($image);
$data = array('title'=>$this->input->post('title'),
'code'=>$this->input->post('code'),
'select_image'=>$this->input->post('select_image'),
'select_wear'=>$this->input->post('select_wear'),
'image'=>$images,
'category_id'=>$this->input->post('subname'),
'size'=>$this->input->post('size'),
'description'=>$this->input->post('description'));
$product=$this->roxmodel->add_gallery($data);
if($product)
{
$data=array();
$colors=array_filter($this->session->userdata('colors'));
/*creating a multidiemensional array to batch insert*/
foreach ($colors as $color)
{
$new_array=array('product_id'=>$product,'color'=>$color);
array_push($data, $new_array);
}
$product=$this->roxmodel->add_product_color($data);
$this->session->unset_userdata('image');
$this->session->unset_userdata('colors');
$this->session->set_flashdata('message', 'Product added Successfully.');
redirect('admin_control/view_images');
}
else
{
//$this->session->unset_userdata('image');
$this->session->set_flashdata('message', 'Insertion Failed.');
redirect('admin_control/add_images');
}
}
//$this->session->unset_userdata('image');
//var_dump($data['sub_category']);
$data['parent']=$this->roxmodel->get_parentcategory();
$this->load->view('add_images',$data);
}
my view page is this...
<?php foreach ($detail as $row) { ?>
<div class="col-md-3 col-sm-1">
<?php $images = json_decode($row->image);
//print_r($images); ?>
<div class="image-box">
<!-- <textarea id="F<?php echo $row->id;?>" hidden> <?php echo $row->image;?></textarea>
<img width="100" src="<?php echo base_url()?>images/<?php echo $images[0] ?>" alt="" file="F<?php echo $row->id;?>" class="img-responsive view-more">
-->
<?php
if($images){
foreach($images as $image):?>
<img width="100" height="100" src="<?php echo base_url();?>images/<?php echo $image;?>" class="img-responsive" alt="">
<?php endforeach;
}
else
{
?>
<img width="100" height="100" src="<?php echo base_url();?>images/<?php echo $row->image;?>" class="img-responsive" alt="">
<?php
};
?>
<div class="edit-box">
<h4><?php echo $row->title; ?>
</h4>
<span class="rg-br" type="button">
<i class="fa fa-pencil-square-o" data-toggle="tooltip" data-placement="bottom" title="Edit"></i>
</span>
<span>
<a class="portfolio" data-toggle="modal" onclick='return deleteItem()' name="delete" id="title" img="img1446224811.jpg" big-img="" title="Delete" href="<?php echo base_url();?>admin_control/delete_image/<?php echo $row->id;?>/<?php echo $row->image;?>"><i class="fa fa-trash-o" data-toggle="tooltip" data-placement="bottom" title="Delete"></i></a></span>
<h5><!-- <?php echo $row->description; ?> --></h5>
</div>
</div>
</div>
<?php } ?>
here the image is not displaying and the value of image in table is getting null

display different image in same div in php

I want to display first image,title and description in col1 div, second in col3 and so on
but in this first image repeat in all div . how to solve this
<?php
include('connection.php');
$perPage=1;
$i=1;
if(isset($_REQUEST['act']) && trim($_REQUEST['act']=='load_data')){
$page=1;
if(!empty($_GET["page"])) {
$page = $_GET["page"];
}
$start = ($page-1)*$perPage;
if($start < 0) $start = 0;
$msg='';
$q="SELECT * FROM addimages order by id desc limit $start,$perPage ";
$res = mysql_query($q);
$row = mysql_fetch_array($res);
$id = $row['art_id'];
$qe="select banner from images where id=$id";
$rs=mysql_query($qe);
$name=mysql_fetch_array($rs);
//$id=$row['id'];
//$no=mysql_num_rows($res);
if(!$row==""){
$msg .= "<div class='article_index' id='".$row["art_id"]."'><div class='article banner_add'><a href='#'><img height='220' src='./uploads/" . $name['banner'] . "' /></a></div>";
$msg .=" <div class='post_main' >
<div class='col1'>
<div class='post_img'><a href='#'><img class='lazy' data-original='./uploads/" . $row['image'] . "' width='633' height='441' src='./uploads/" . $row['image'] . "' style='display: inline;' /></a>
</div>
<div class='post_contant_main'>
<div class='post_title'><h2><a href='#'>".$row['title']."</a></h2></div>
<div class='post_contant'>".$row['desc']."</div>
</div>
</div>";
$msg .=" <div class='col3'>
<div class='post_img'><a href='#'><img class='lazy' width='299' height='191' src='./uploads/" . $row['image'] . "' style='display: inline;' /></a>
</div>
<div class='post_contant_main'>
<div class='post_title post_rtitle'><h2><a href='#'>".$row['title']."</a></h2></div>
</div>
</div>
<div class='col3'>
<div class='post_img'><a href='#'><img class='lazy' width='299' height='191' src='./uploads/" . $row['image'] . "' style='display: inline;' /></a>
</div>
<div class='post_contant_main'>
<div class='post_title post_rtitle'><h2><a href='#'>".$row['title']."</a></h2></div>
</div>
</div>
<div class='col2'>
<div class='post_img'><a href='#'><img class='lazy' width='461' height='300' src='./uploads/" . $row['image'] . "' style='display: inline;' /></a>
</div>
<div class='post_contant_main'>
<div class='post_title'><h2><a href='#'>".$row['title']."</a></h2></div>
<div class='post_contant'>".$row['desc']."</div>
</div>
</div>
<div class='col2'>
<div class='post_img'><a href='#'><img class='lazy' width='461' height='300' src='./uploads/" . $row['image'] . "' style='display: inline;' /></a>
</div>
<div class='post_contant_main'>
<div class='post_title'><h2><a href='#'>".$row['title']."</a></h2></div>
<div class='post_contant'>".$row['desc']."</div>
</div>
</div>
</div>
</div>
";
}
$msg .="<a class='next' href='#'></a>
<input type='hidden' id='pageno' name='pageno' value=''>";
echo $msg;
}
?>
i want to increase row array to next id and display its content
i am using infinite scroll plugin
you fetch only one top row. If you want to get all rows, you need to loop it thought.
while ($row = $result->fetch_row()) {
$msg .=" <div class='post_main' >
<div class='col1'>
<div class='post_img'><a href='#'><img class='lazy' data-original='./uploads/" . $row['image'] . "' width='633' height='441' src='./uploads/" . $row['image'] . "' style='display: inline;' /></a>
</div>
<div class='post_contant_main'>
<div class='post_title'><h2><a href='#'>".$row['title']."</a></h2></div>
<div class='post_contant'>".$row['desc']."</div>
</div>
</div>";
}

Php code in html not working as expected

I want to use this code to get results from my database and show it in html but this is not happening. Getting all weird results and am not able to fix it.
it display } ? > on my webpage at the end wonder why.And i cannot get any results from my database displayed either.
Database is proper I believe some error in html and php code(php variables in html tags).
<?php
while($row = mysqli_fetch_array($result)) {
$price = ($row['ISBN']%1000);
echo $price;
<li>
<div class="book-display-bg">
<div class="book-display-placeholder">
<div class="book-display-container">
<div class="book-display-centered">
<a href='product/taqatu-niran-min-yaumiyat-al-intifada-as-suriya-9789953892368-(105523).html' >
<img src=''$row['Image_URL_M']'' style='border: 0;' alt=''$row['Book_Title']''/>
</a>
</div>
</div>
</div>
</div>
<div class="book-display-details">
<div class="book-display-title"><p><a href='product/taqatu-niran-min-yaumiyat-al-intifada-as-suriya-9789953892368-(105523).html' title=''$row['Book_Title']'' >$row['Book_Title']</a></p></div>
<div class="book-display-author"><p>$row['Book_Author']</p></div>
<div id="ctl00_ctl00_CMSContentMasterPlaceHolder_cphContent1_ctl01_ProductSummary1_DataList1_ctl02_divStock" class="book-display-stock"></div>
<div class="book-display-price">$price</div>
<input type="submit" name="ctl00$ctl00$CMSContentMasterPlaceHolder$cphContent1$ctl01$ProductSummary1$DataList1$ctl02$btnBuyNow" value="add to basket" id="ctl00_ctl00_CMSContentMasterPlaceHolder_cphContent1_ctl01_ProductSummary1_DataList1_ctl02_btnBuyNow" title="add to basket" class="ecom-add-basket" />
</div>
<div class="clear"></div>
</li>
}
?>
Thanks in advance
You forget to add echo for the li element. You can try following:
<?php
while($row = mysqli_fetch_array($result)) {
$price = ($row['ISBN']%1000);
echo $price; ?>
<li>
<div class="book-display-bg">
<div class="book-display-placeholder">
<div class="book-display-container">
<div class="book-display-centered">
<a href='product/taqatu-niran-min-yaumiyat-al-intifada-as-suriya-9789953892368-(105523).html' >
<img src='<?php echo $row['Image_URL_M']; ?>' style='border: 0;' alt='<?php echo $row['Book_Title']; ?>'/>
</a>
</div>
</div>
</div>
</div>
<div class="book-display-details">
<div class="book-display-title"><p><a href='product/taqatu-niran-min-yaumiyat-al-intifada-as-suriya-9789953892368-(105523).html' title='<?php echo $row['Book_Title']; ?>' ><?php echo $row['Book_Title']; ?></a></p></div>
<div class="book-display-author"><p><?php echo $row['Book_Author']; ?></p></div>
<div id="ctl00_ctl00_CMSContentMasterPlaceHolder_cphContent1_ctl01_ProductSummary1_DataList1_ctl02_divStock" class="book-display-stock"></div>
<div class="book-display-price"><?php echo $price; ?></div>
<input type="submit" name="ctl00$ctl00$CMSContentMasterPlaceHolder$cphContent1$ctl01$ProductSummary1$DataList1$ctl02$btnBuyNow" value="add to basket" id="ctl00_ctl00_CMSContentMasterPlaceHolder_cphContent1_ctl01_ProductSummary1_DataList1_ctl02_btnBuyNow" title="add to basket" class="ecom-add-basket" />
</div>
<div class="clear"></div>
</li><?php
}
?>
or You can do it this way:
<?php
while($row = mysqli_fetch_array($result)) {
$price = ($row['ISBN']%1000);
echo $price;
echo '<li>
<div class="book-display-bg">
<div class="book-display-placeholder">
<div class="book-display-container">
<div class="book-display-centered">
<a href="product/taqatu-niran-min-yaumiyat-al-intifada-as-suriya-9789953892368-(105523).html" >
<img src="' . $row['Image_URL_M'] . '" style="border: 0;" alt="$row[\'Book_Title\']"/>
</a>
</div>
</div>
</div>
</div>
<div class="book-display-details">
<div class="book-display-title"><p><a href="product/taqatu-niran-min-yaumiyat-al-intifada-as-suriya-9789953892368-(105523).html" title="' . $row['Book_Title'] . '" >' . $row['Book_Title'] . '</a></p></div>
<div class="book-display-author"><p> ' .$row['Book_Author'] . '</p></div>
<div id="ctl00_ctl00_CMSContentMasterPlaceHolder_cphContent1_ctl01_ProductSummary1_DataList1_ctl02_divStock" class="book-display-stock"></div>
<div class="book-display-price">' . $price . '</div>
<input type="submit" name="ctl00$ctl00$CMSContentMasterPlaceHolder$cphContent1$ctl01$ProductSummary1$DataList1$ctl02$btnBuyNow" value="add to basket" id="ctl00_ctl00_CMSContentMasterPlaceHolder_cphContent1_ctl01_ProductSummary1_DataList1_ctl02_btnBuyNow" title="add to basket" class="ecom-add-basket" />
</div>
<div class="clear"></div>
</li>';
}
?>
hope it helped
Please do use open and close braces correctly.
If you want to use the HTMl code in php then all you have to do is echo
for example:
<?php
while($row = mysqli_fetch_array($result)) {
echo "<div class='book-display-centered'>{$row['Book_Author']}</div>"
}
?>
And since you have lot of data in html you can use it like this
<?php
while($row = mysqli_fetch_array($result)) {
?>
<div class='book-display-centered'><?php echo $row['Book_Author'] ?></div>
<?php
}
?>
You must echo html content or close php tag before them
Try this:
<?php
while($row = mysqli_fetch_array($result)) {
$price = ($row['ISBN']%1000);
echo $price;
?>
<li>
<div class="book-display-bg">
<div class="book-display-placeholder">
<div class="book-display-container">
<div class="book-display-centered">
<a href='product/taqatu-niran-min-yaumiyat-al-intifada-as-suriya-9789953892368-(105523).html' >
<img src="<?php echo $row['Image_URL_M']?>" style='border: 0;' alt=" <?php echo $row['Book_Title']?>"/>
</a>
</div>
</div>
</div>
</div>
<div class="book-display-details">
<div class="book-display-title"><p><a href='product/taqatu-niran-min-yaumiyat-al-intifada-as-suriya-9789953892368-(105523).html' title="<?php echo $row['Book_Title'] ?>" > <?php echo $row['Book_Title']?></a></p></div>
<div class="book-display-author"><p><?php echo $row['Book_Author'] ?></p></div>
<div id="ctl00_ctl00_CMSContentMasterPlaceHolder_cphContent1_ctl01_ProductSummary1_DataList1_ctl02_divStock" class="book-display-stock"></div>
<div class="book-display-price"><?php echo $price ?></div>
<input type="submit" name="ctl00$ctl00$CMSContentMasterPlaceHolder$cphContent1$ctl01$ProductSummary1$DataList1$ctl02$btnBuyNow" value="add to basket" id="ctl00_ctl00_CMSContentMasterPlaceHolder_cphContent1_ctl01_ProductSummary1_DataList1_ctl02_btnBuyNow" title="add to basket" class="ecom-add-basket" />
</div>
<div class="clear"></div>
</li>
<?php
}
?>
Use below code...
while($row = mysqli_fetch_array($result)) {
$price = ($row['ISBN']%1000);
echo $price;
?>
<li>
<div class="book-display-bg">
<div class="book-display-placeholder">
<div class="book-display-container">
<div class="book-display-centered">
<a href='product/taqatu-niran-min-yaumiyat-al-intifada-as-suriya-9789953892368-(105523).html' >
<img src=''$row['Image_URL_M']'' style='border: 0;' alt=''$row['Book_Title']''/>
</a>
</div>
</div>
</div>
</div>
<div class="book-display-details">
<div class="book-display-title"><p><a href='product/taqatu-niran-min-yaumiyat-al-intifada-as-suriya-9789953892368-(105523).html' title=''$row['Book_Title']'' >$row['Book_Title']</a></p></div>
<div class="book-display-author"><p>$row['Book_Author']</p></div>
<div id="ctl00_ctl00_CMSContentMasterPlaceHolder_cphContent1_ctl01_ProductSummary1_DataList1_ctl02_divStock" class="book-display-stock"></div>
<div class="book-display-price">$price</div>
<input type="submit" name="ctl00$ctl00$CMSContentMasterPlaceHolder$cphContent1$ctl01$ProductSummary1$DataList1$ctl02$btnBuyNow" value="add to basket" id="ctl00_ctl00_CMSContentMasterPlaceHolder_cphContent1_ctl01_ProductSummary1_DataList1_ctl02_btnBuyNow" title="add to basket" class="ecom-add-basket" />
</div>
<div class="clear"></div>
</li>
<?php
}
?>

Dynamic CSS ID with PHP

A newbie here. Trying to increment CSS ID selector with PHP.
Following the code I have
<?php
$thumbnails = get_post_meta($post->ID, "plans", false);
if ($thumbnails[0] != '') :?>
<div id="images-box">
<?php foreach($thumbnails as $thumb) {
echo '<div class="holder">
<div id="image-'. $id .'" class="image-lightbox">
<span class="close">X</span>
<img src="' . $thumb . '" alt="" />
<a class="expand" href="#image-1"></a>
</div>';
} ?>
</div>
<?php endif; ?>
What I want is
<div id="image-1" class="image-lightbox">
<div id="image-2" class="image-lightbox">
<div id="image-3" class="image-lightbox">
I tried with many options that were answered here (http://codepad.org/OHuTxQPI) but couldn't get it right.
Simply add $id=1; and $id++; in your code.
<?php
$id = 1;
foreach($thumbnails as $thumb) {
echo '<div class="holder">
<div id="image-'. $id .'" class="image-lightbox">
<span class="close">X</span>
<img src="' . $thumb . '" alt="" />
<a class="expand" href="#image-1"></a>
</div>';
$id++;
} ?>
Edited: $id=1; should be used if you want to start from id='image-1'.
You're using $id as a counter but don't actually define or increment anywehre.
<?php
$thumbnails = get_post_meta($post->ID, "plans", false);
if ($thumbnails[0] != '') :?>
<div id="images-box">
<?php
$id = 0;
foreach($thumbnails as $thumb) {
echo '<div class="holder">
<div id="image-'. $id .'" class="image-lightbox">
<span class="close">X</span>
<img src="' . $thumb . '" alt="" />
<a class="expand" href="#image-1"></a>
</div>';
$id++;
} ?>
</div>
<?php endif; ?>
Unlike the rest, I'm using a straight for() loop instead of foreach() to give more control (ok it's really just cuz I'm OCD and like to use $i).
Here's the demo
PHP:
<?php
$thumbnails = array(0 => array('thumb' => 'image.jpg'), 1 => array('thumb' => 'image2.jpg'));
// $thumbnails = get_post_meta($post->ID, "plans", false);
if (isset($thumbnails)): ?>
<div id="images-box">
<?php
$i = 0;
$thumbs = count($thumbnails);
for($i;$i < $thumbs;$i++) { ?>
<div class="holder">
<div id="image-<?php print $i; ?>" class="image-lightbox">
<span class="close">X</span>
<img src="<?php print $thumbnails[$i]['thumb']; ?>" alt="" />
<a class="expand" href="#image-<?php print $i; ?>"></a>
</div>
<?php }; ?>
</div>
<?php endif; ?>
HTML output:
<div id="images-box">
<div class="holder">
<div id="image-0" class="image-lightbox">
<span class="close">X</span>
<img src="image.jpg" alt="" />
<a class="expand" href="#image-0"></a>
</div>
<div class="holder">
<div id="image-1" class="image-lightbox">
<span class="close">X</span>
<img src="image2.jpg" alt="" />
<a class="expand" href="#image-1"></a>
</div>
</div>
Use Counter for $id as told by John or use $id as index for foreach loop as below.
<?php
$thumbnails = get_post_meta($post->ID, "plans", false);
if ($thumbnails[0] != '') :?>
<div id="images-box">
<?php foreach($thumbnails as $id=> $thumb) {
echo '<div class="holder">
<div id="image-'. $id .'" class="image-lightbox">
<span class="close">X</span>
<img src="' . $thumb . '" alt="" />
<a class="expand" href="#image-1"></a>
</div>';
} ?>
</div>
<?php endif; ?>

Categories