PHP and XML image gallery variable issue

Posted on 16th Feb 2014 07:03 pm by admin

I'm trying to display the large image on the same page as the thumbnails, to do that I'm passing a variable called $current. I know that the code to display large image works, because it works when no variables are passed along, in which case $current set to 0, but when i click on any other thumbnail, the xml info doesn't seem to be passed along. I check if $current is passed into test_table.php in the top right corner so I know that works. So I'm stuck, please help! Thanks!

The problem page can be found here:

Code: [Select]<?php
include 'carpets.php';
$xml = new SimpleXMLElement($xmlstr);
$item_count=-1; //fixes item count
if (isset($id)==false){
if (isset($page)==false){
foreach ($xml->rug as $rugs) {
if (isset($current)==false){

if(($item_count/15)-($pages*15)!=0){ // adjusts page number for overflow


<table cellpadding="0" cellspacing="0" align="left" class="display">
<table width="260" height="435" cellpadding="0" cellspacing="0">
<?php for ($i=0;$i<=4;$i++){ ?>
<tr height="85" valign="top">
<?php for ($j=0;$j<=2;$j++){?>
<?php if(isset($xml->rug[$id_count]->filename)==true){ ?> <!-- gets rid of empty images -->
<a href="test_table.php?page=<?php echo $page; ?>&id=<?php echo $id_count?>&id_current=<?php echo $id_count?>"><img src="images/small/<?php echo $xml->rug[$id_count]->filename?>.jpg" border="0"></a>
<?php $id_count++; }?>
<?php //echo $xml->rug[$count]->filename;?>
<td width="5"></td>
<?php }?>
<?php }?>
<!--displays page numbers and links -->
<?php // $id_start=($page-1)*15;?>
<?php for ($k=1;$k<=$pages;$k++) {
if($page==$k) {?>
<b><?php echo $page; ?></b>
<?php } else {?>
<a href="test_table.php?page=<?php echo $k; ?>&id=<?php echo ($k-1)*15?>&id_current=<?php echo ($k-1)*15?>"><?php echo $k; ?></a>
<?php } ?>
<?php } ?>
</td><!--end of thubnails -->
<td width="388"valign="top" align="center">
<div class="image_large"><a href="images/large/<?php echo $xml->rug[$current]->filename?>.jpg" class="lightwindow hidden" rel="Random[Sample Images]" caption="<?php echo $xml->rug[$current]->rugname, $xml->rug[$current]->color, $xml->rug[$current]->size?>"><img src="images/large/<?php echo $xml->rug[$current]->filename?>.jpg" border="0" height="420" width="300"></a></div>
</td><!--end of large_image -->
<td width="98" valign="top" align="right">
Test $current: <?php echo $current ?><br />
Series: <?php echo $xml->rug[$current]->series?><br />
Name: <?php echo $xml->rug[$current]->rugname?><br />
Color: <?php //if (($xml->rug[$current]->color)==""){
//echo "as shown"; }else {}
echo $xml->rug[$current]->color;?><br />
Size: <?php echo $xml->rug[$current]->size?>
</td><!--end of rug_info -->


No comments posted yet

Your Answer:

Login to answer
204 Like 52 Dislike
Previous forums Next forums
Other forums

Select Rows as Columns..
is there a way to select COLUMN_NAME from user_tab_columns where table_name='TABLENAME';
and ha

Problem with PHP code- simple contact form
I'm relativily new to PHP; I know HTML and CSS stuff but I have a problem- I have a contact form wit

Only add new information from XML to MySQL
What I am doing, is taking a xml file, and adding the values to a database. However, what I want to

undefined offset help
Hi All,

I kept getting undefined offset PHP notice for a simple for loop. For eg
$va = arr

Limiting uploaded file type
Hi. First post here
I am working on a simple upload script, and I need it to limit the allowed f

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS

Play Free Quiz and Win Cash