katnyc Posted October 16, 2009 Share Posted October 16, 2009 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: http://brooklynthings.com/tibet_carpet_test/test_table.php <?php include 'carpets.php'; $xml = new SimpleXMLElement($xmlstr); $item_count=-1; //fixes item count $id=$_GET['id']; if (isset($id)==false){ $id=0; } $page=$_GET['page']; if (isset($page)==false){ $page=1; } $id_count=($page-1)*15; foreach ($xml->rug as $rugs) { $item_count++; } $current=$_GET['id_current']; if (isset($current)==false){ $current=0; } $pages=round($item_count/15); if(($item_count/15)-($pages*15)!=0){ // adjusts page number for overflow $pages++; } ?> <center> <table cellpadding="0" cellspacing="0" align="left" class="display"> <tr> <td> <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++){?> <td> <?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> <td width="5"></td> <?php }?> </tr> <?php }?> </table> <!--displays page numbers and links --> <?php // $id_start=($page-1)*15;?> page <?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 --> </table> Quote Link to comment Share on other sites More sharing options...
katnyc Posted October 17, 2009 Author Share Posted October 17, 2009 Maybe someone can help out today? I'm really stuck here. Thank you! Quote Link to comment Share on other sites More sharing options...
Dorky Posted October 17, 2009 Share Posted October 17, 2009 if (isset($id)==false){ $id=0; } //should be if (!isset($id)){ $id=0; } i see a lot of things like that in your code. like all the stop and start of <?php did you write this? most of these guys want you to have some understanding of what the code does. im still only less then a year into php but i would suggest dissecting the code parts and researching them and in that you will find the answers you seek. if not at least you can make the code more presentable and pose a more targeted question. Quote Link to comment Share on other sites More sharing options...
katnyc Posted October 17, 2009 Author Share Posted October 17, 2009 Thanks for replying dorky. Yes, i did write that part, your suggestion makes more sense ... as you can see I'm a beginner in this, I'll try to clean up the code as you suggested and maybe that will help me solve the issue and if not, i'll come back with a cleaner code... thanks again! Quote Link to comment Share on other sites More sharing options...
Dorky Posted October 17, 2009 Share Posted October 17, 2009 Thanks for replying dorky. Yes, i did write that part, your suggestion makes more sense ... as you can see I'm a beginner in this, I'll try to clean up the code as you suggested and maybe that will help me solve the issue and if not, i'll come back with a cleaner code... thanks again! word Quote Link to comment Share on other sites More sharing options...
katnyc Posted October 17, 2009 Author Share Posted October 17, 2009 Ok, so I've isolated the problem to fewer lines, which should be easier to digest... This link works, and item 0 is accessed: http://www.brooklynthings.com/tibet_carpet_test/large_image.php But if I try to pass the item id in the URL, it for some reason no longer is able to access the items is the XML: http://www.brooklynthings.com/tibet_carpet_test/large_image.php?id=0 . I've checked my sytax, all seems well... is there something I'm missing about how XML and php work? <?php include 'carpets.php'; $xml2 = new SimpleXMLElement($xmlstr); $current=$_GET['id']; //passed in URL to display large pic and carpet info if (!isset($current)){//sets current to 0, if nothing is in URL $current=0; } ?> <table width="388"valign="top" align="center"> <tr> <td> <div class="image_large"> <img src="images/large/<?php echo $xml2->rug[$current]->filename?>.jpg" border="0" height="420" width="300"> </div><!--end of large_image --> </td> <td width="98" valign="top" align="right"> Test $current: <?php echo $current ?><br /> Test xml: <?php if (!isset($xml2->rug[$current]->series)) echo "xml not set"; else echo "xml ok"; ?><br /> </td><!--end of rug_info --> </tr> </table> My xml looks like this, there are about 17 items in there: <?php $xmlstr = <<<XML <rugs> <rug> <series>Cultural</series> <filename>cultural_AT-108</filename> <rugname></rugname> <color></color> <size>3 x 4 feet</size></rug> <rug> <series>Cultural</series> <filename>cultural_AT-109</filename> <rugname></rugname> <color></color> <size>16 x 24 inches</size></rug> </rugs> XML; ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.