473,796 Members | 2,728 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Table formatted foreach loop to display images.

1 New Member
Hi,
Please help me to get images in table format. I'm new to PHP.

I have written code to display images in a table format and it displays only 9 images in a single page. when i click Next Url to go to next page, by default it returns to home page. I stored images in local directory and written for each loop to display images in table format. Without using mysql as backend.

My question is how to display bunch of images in table formated (3x3) column and rows format with next link to navigate to the next page?

My code is as :
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. /* final code for use with directoritems class after navigator
  3. is created */
  4. require 'PageNavigator.php';
  5. require 'DirectoryItems.php';
  6. //max per page
  7. define("PERPAGE", 9);
  8. //name of first parameter in query string
  9. define("OFFSET", "offset");
  10. /*get query string - name should be same as first parameter name
  11. passed to the page navigator class*/
  12. $offset=@$_GET[OFFSET];
  13. //check variable
  14. if (!isset($offset))
  15. {
  16.     $totaloffset=0;
  17. }
  18. else
  19. {
  20.     //clean variable here
  21.     //then calc record offset
  22.     $totaloffset = $offset * PERPAGE;
  23. }
  24. $di = new DirectoryItems("My Directory name");
  25. $di->imagesOnly();
  26. $di->naturalCaseInsensitiveOrder();
  27. //get portion of array
  28. $filearray = $di->getFileArraySlice($totaloffset, PERPAGE);
  29. echo "<div style=\"text-align:center;\">";
  30. //echo "Click the file name to view full-sized version.<br />";
  31. $path = "";
  32. //specify size of thumbnail
  33. $size = 100;    
  34. //use SEPARATOR
  35. echo "<table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"1\"><tr>";
  36. $imgcount=0;
  37. foreach ($filearray as $key => $value)
  38. {
  39.     echo "<td align=\"center\" width=\"33%\" valign=\"top\">";
  40.     $path = "{$di->getDirectoryName()}/$key";    
  41.     /*errors in getthumb or in class will result in broken links
  42.     - error will not display*/
  43.     echo "<img src=\"getthumb.php?path=$path&amp;size=$size\" width=\"100\" height=\"100\" ".
  44.             "alt=\"$value\" /><br />\n";
  45.     echo "<a href=\"$path\" target=\"_blank\" >";
  46.     echo "$value</a><br><br><br />\n";
  47.     echo "</td>";
  48.     $imgcount++;
  49.     if ($imgcount%3==0)
  50.     {
  51.         echo "</tr><tr>";
  52.     }
  53. }
  54. echo "</tr></table>";
  55. echo "</div><br />";
  56. $pagename = basename($_SERVER["PHP_SELF"]);
  57. $totalcount = $di->getCount();
  58. $numpages = ceil($totalcount/PERPAGE);
  59. //create if needed
  60. if($numpages > 1)
  61. {
  62.   //create navigator
  63.   $nav = new PageNavigator($pagename, $totalcount, PERPAGE, $totaloffset);
  64.     //is the default but make explicit
  65.     $nav->setFirstParamName(OFFSET);
  66.   echo $nav->getNavigator();
  67. }
  68. ?>
When i click next it goes to home page.

My Page Navigator code is as :
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. ////////////////////////////////////////////////////////////////////
  3. /**
  4. Class for navigating over multiple pages
  5. */
  6. class PageNavigator{
  7.   //data members
  8.   private $pagename;
  9.   private $totalpages;
  10.   private $recordsperpage;
  11.   private $maxpagesshown;
  12.   private $currentstartpage;
  13.   private $currentendpage;
  14.   private $currentpage;
  15.   //next and previous inactive
  16.   private $spannextinactive;
  17.   private $spanpreviousinactive;
  18.   //first and last inactive
  19.   private $firstinactivespan;
  20.   private $lastinactivespan;  
  21.   //must match $_GET['offset'] in calling page
  22.   private $firstparamname = "offset";
  23.   //use as "&name=value" pair for getting
  24.   private $params;
  25.   //css class names
  26.   private $inactivespanname = "inactive";
  27.   private $pagedisplaydivname = "totalpagesdisplay";
  28.   private $divwrappername = "navigator";
  29.   //text for navigation
  30.   private $strfirst = "|&lt;";
  31.   private $strnext = "Next";
  32.   private $strprevious = "Prev";
  33.   private $strlast = "&gt;|";
  34.   //for error reporting
  35.   private $errorstring;  
  36. ////////////////////////////////////////////////////////////////////
  37. //constructor
  38. ////////////////////////////////////////////////////////////////////
  39.   public function __construct($pagename, $totalrecords, $recordsperpage, $recordoffset, $maxpagesshown = 4, $params = ""){
  40.     $this->pagename = $pagename;
  41.     $this->recordsperpage = $recordsperpage;  
  42.     $this->maxpagesshown = $maxpagesshown;
  43.     //already urlencoded
  44.     $this->params = $params;
  45.     //check recordoffset a multiple of recordsperpage
  46.     $this->checkRecordOffset($recordoffset, $recordsperpage) or
  47.       die($this->errorstring);
  48.     $this->setTotalPages($totalrecords, $recordsperpage);
  49.     $this->calculateCurrentPage($recordoffset, $recordsperpage);
  50.     $this->createInactiveSpans();
  51.     $this->calculateCurrentStartPage();
  52.     $this->calculateCurrentEndPage();
  53.   }
  54. ////////////////////////////////////////////////////////////////////
  55. //public methods
  56. ////////////////////////////////////////////////////////////////////
  57. //give css class name to inactive span
  58. ////////////////////////////////////////////////////////////////////
  59.   public function setInactiveSpanName($name){
  60.     $this->inactivespanname = $name;
  61.     //call function to rename span
  62.     $this->createInactiveSpans();  
  63.   }
  64. ////////////////////////////////////////////////////////////////////
  65.   public function getInactiveSpanName(){
  66.     return $this->inactivespanname;
  67.   }
  68. ////////////////////////////////////////////////////////////////////
  69.   public function setPageDisplayDivName($name){
  70.     $this->pagedisplaydivname = $name;    
  71.   }
  72. ////////////////////////////////////////////////////////////////////
  73.   public function getPageDisplayDivName(){
  74.     return $this->pagedisplaydivname;
  75.   }
  76. ////////////////////////////////////////////////////////////////////
  77.   public function setDivWrapperName($name){
  78.     $this->divwrappername = $name;    
  79.   }
  80. ////////////////////////////////////////////////////////////////////
  81.   public function getDivWrapperName(){
  82.     return $this->divwrappername;
  83.   }
  84. ////////////////////////////////////////////////////////////////////
  85.   public function setFirstParamName($name){
  86.     $this->firstparamname = $name;    
  87.   }
  88. ////////////////////////////////////////////////////////////////////
  89.   public function getFirstParamName(){
  90.     return $this->firstparamname;
  91.   }
  92. ////////////////////////////////////////////////////////////////////
  93. /**
  94. Returns HTML code for the navigator
  95. */
  96.   public function getNavigator(){
  97.     //wrap in div tag
  98.     $strnavigator = "<div class=\"$this->divwrappername\">\n";
  99.     //output movefirst button    
  100.     if($this->currentpage == 0){
  101.       $strnavigator .= $this->firstinactivespan;
  102.     }else{
  103.       $strnavigator .= $this->createLink(0, $this->strfirst);
  104.     }
  105.     //output moveprevious button
  106.     if($this->currentpage == 0){
  107.       $strnavigator .= $this->spanpreviousinactive;
  108.     }else{
  109.       $strnavigator.= $this->createLink($this->currentpage-1, $this->strprevious);
  110.     }
  111.     //loop through displayed pages from $currentstart
  112.     for($x = $this->currentstartpage; $x < $this->currentendpage; $x++){
  113.       //make current page inactive
  114.       if($x == $this->currentpage){
  115.         $strnavigator .= "<span class=\"$this->inactivespanname\">";
  116.         $strnavigator .= $x+1;
  117.         $strnavigator .= "</span>\n";
  118.       }else{
  119.         $strnavigator .= $this->createLink($x, $x+1);
  120.       }
  121.     }
  122.     //next button    
  123.     if($this->currentpage == $this->totalpages-1){
  124.       $strnavigator .= $this->spannextinactive;      
  125.     }else{
  126.       $strnavigator .= $this->createLink($this->currentpage + 1, $this->strnext);
  127.     }
  128.     //move last button
  129.     if($this->currentpage == $this->totalpages-1){
  130.       $strnavigator .= $this->lastinactivespan;
  131.     }else{
  132.       $strnavigator .= $this->createLink($this->totalpages -1, $this->strlast);
  133.     }
  134.     $strnavigator .=  "</div>\n";
  135.     $strnavigator .= $this->getPageNumberDisplay();
  136.     return $strnavigator;
  137.   }
  138. ////////////////////////////////////////////////////////////////////
  139. //private methods
  140. ////////////////////////////////////////////////////////////////////
  141.   private function createLink($offset, $strdisplay ){
  142.     $strtemp = "<a href=\"$this->pagename?$this->firstparamname=";
  143.     $strtemp .= $offset;
  144.     $strtemp .= "$this->params\">$strdisplay</a>\n";
  145.     return $strtemp;
  146.   }
  147. ////////////////////////////////////////////////////////////////////  
  148.   private function getPageNumberDisplay(){
  149.     $str = "<div class=\"$this->pagedisplaydivname\">\nPage ";
  150.     $str .= $this->currentpage+1;
  151.     $str .= " of $this->totalpages";
  152.     $str .= "</div>\n";
  153.     return $str;
  154.   }
  155. ////////////////////////////////////////////////////////////////////
  156.   private function setTotalPages($totalrecords, $recordsperpage){
  157.     $this->totalpages = ceil($totalrecords/$recordsperpage);
  158.   }
  159. ////////////////////////////////////////////////////////////////////
  160.   private function checkRecordOffset($recordoffset, $recordsperpage){
  161.     $bln = true;
  162.     if($recordoffset%$recordsperpage != 0){
  163.       $this->errorstring = "Error - not a multiple of records per page.";
  164.       $bln = false;  
  165.     }
  166.     return $bln;
  167.   }
  168. ////////////////////////////////////////////////////////////////////  
  169.   private function calculateCurrentPage($recordoffset, $recordsperpage){
  170.     $this->currentpage = $recordoffset/$recordsperpage;
  171.   }
  172. ////////////////////////////////////////////////////////////////////
  173. // not always needed but create anyway
  174. ////////////////////////////////////////////////////////////////////
  175.   private function createInactiveSpans(){
  176.     $this->spannextinactive = "<span class=\"".
  177.       "$this->inactivespanname\">$this->strnext</span>\n";
  178.     $this->lastinactivespan = "<span class=\"".
  179.       "$this->inactivespanname\">$this->strlast</span>\n";
  180.     $this->spanpreviousinactive = "<span class=\"".
  181.       "$this->inactivespanname\">$this->strprevious</span>\n";
  182.     $this->firstinactivespan = "<span class=\"".
  183.       "$this->inactivespanname\">$this->strfirst</span>\n";
  184.   }
  185. ////////////////////////////////////////////////////////////////////
  186. // find start page based on current page
  187. ////////////////////////////////////////////////////////////////////
  188.   private function calculateCurrentStartPage(){
  189.     $temp = floor($this->currentpage/$this->maxpagesshown);
  190.     $this->currentstartpage = $temp * $this->maxpagesshown;
  191.   }
  192. ////////////////////////////////////////////////////////////////////
  193.   private function calculateCurrentEndPage(){
  194.     $this->currentendpage = $this->currentstartpage+$this->maxpagesshown;
  195.     if($this->currentendpage > $this->totalpages)
  196.     {
  197.       $this->currentendpage = $this->totalpages;
  198.     }
  199.   }
  200. }//end class
  201. ////////////////////////////////////////////////////////////////////
  202. ?>
My Directory Items code is as:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. class DirectoryItems
  4. {
  5.     //data members
  6.     private $filearray = array();
  7.     private $replacechar;
  8.     private $directory;
  9.  
  10.   public function __construct($directory, $replacechar = "_")
  11.   {
  12.         $this->directory = $directory;
  13.         $this->replacechar = $replacechar;
  14.         $d = "";
  15.       if(is_dir($directory))
  16.     {
  17.           $d = opendir($directory) or die("Failed to open directory.");
  18.           while(false !== ($f = readdir($d)))
  19.       {
  20.             if(is_file("$directory/$f"))
  21.         {
  22.                     $title = $this->createTitle($f);
  23.                     $this->filearray[$f] = $title;
  24.             }
  25.           }
  26.             closedir($d);
  27.         }
  28.     else
  29.     {
  30.             //error
  31.             die("Must pass in a directory.");
  32.         }
  33.     }
  34. //////////////////////////////////////////////////////////////////
  35. //destructor
  36. //////////////////////////////////////////////////////////////////
  37.     public function __destruct()
  38.   {
  39.         unset($this->filearray);
  40.     }
  41. //////////////////////////////////////////////////////////////////
  42. //public fuctions
  43. //////////////////////////////////////////////////////////////////
  44.     public function getDirectoryName()
  45.   {
  46.         return $this->directory;
  47.     }
  48. //////////////////////////////////////////////////////////////////
  49.     public function indexOrder()
  50.   {
  51.         sort($this->filearray);
  52.     }
  53. //////////////////////////////////////////////////////////////////
  54.     public function naturalCaseInsensitiveOrder()
  55.   {
  56.         natcasesort($this->filearray);
  57.     }
  58. //////////////////////////////////////////////////////////////////
  59. //returns false if files are not all images of these types
  60. //////////////////////////////////////////////////////////////////
  61.     public function checkAllImages()
  62.   {
  63.         $bln = true;
  64.         $extension = "";
  65.         $types = array("jpg", "jpeg", "gif", "png");
  66.         foreach ($this->filearray as $key => $value)
  67.     {
  68.             $extension = substr($key,(strpos($key, ".")+1));
  69.             $extension = strtolower($extension);
  70.             if(!in_array($extension, $types))
  71.       {
  72.                 $bln = false;
  73.                 break;
  74.             }
  75.         }
  76.         return $bln;
  77.     }
  78. //////////////////////////////////////////////////////////////////
  79. //returns false if not all specified extension 
  80. //////////////////////////////////////////////////////////////////
  81.     public function checkAllSpecificType($extension)
  82.   {
  83.         $extension = strtolower($extension);
  84.         $bln = true;
  85.         $ext = "";
  86.         foreach ($this->filearray as $key => $value)
  87.     {
  88.             $ext = substr($key,(strpos($key, ".")+1));
  89.             $ext = strtolower($ext);
  90.             if($extension != $ext)
  91.       {
  92.                 $bln=false;
  93.                 break;
  94.             }
  95.         }
  96.         return $bln;
  97.     }
  98. //////////////////////////////////////////////////////////////////
  99.     public function getCount()
  100.   {
  101.         return count($this->filearray);
  102.     }
  103. //////////////////////////////////////////////////////////////////
  104.     public function getFileArray()
  105.   {
  106.         return $this->filearray;
  107.     }
  108. //////////////////////////////////////////////////////////////////
  109. //for use with navigator - Phase 3
  110. /////////////////////////////////////////////////////////////////
  111.     public function getFileArraySlice($start, $length)
  112.   {
  113.         return array_slice($this->filearray, $start, $length);
  114.     }
  115. //////////////////////////////////////////////////////////////////
  116. //eliminate all elements from array except specified extension - Phase 2
  117. /////////////////////////////////////////////////////////////////
  118.     public function filter($extension)
  119.   {
  120.         $extension = strtolower($extension);
  121.         foreach ($this->filearray as $key => $value)
  122.     {
  123.             $ext = substr($key,(strpos($key, ".") + 1));
  124.             $ext = strtolower($ext);
  125.             if($ext != $extension)
  126.       {
  127.                 unset($this->filearray[$key]);
  128.             }
  129.         }
  130.     }
  131. //////////////////////////////////////////////////////////////////
  132. //eliminate all elements from array except images - Phase 2
  133. /////////////////////////////////////////////////////////////////
  134.     public function imagesOnly()
  135.   {
  136.         $extension = "";
  137.         $types = array("jpg", "jpeg", "gif", "png");
  138.         foreach ($this->filearray as $key => $value)
  139.     {
  140.             $extension = substr($key,(strpos($key, ".") + 1));
  141.             $extension = strtolower($extension);
  142.             if(!in_array($extension, $types))
  143.       {
  144.                 unset($this->filearray[$key]);
  145.             }
  146.         }    
  147.     }
  148. //////////////////////////////////////////////////////////////////
  149. //recreate array after filtering - Phase 2
  150. /////////////////////////////////////////////////////////////////
  151.     public function removeFilter()
  152.   {
  153.         unset($this->filearray);
  154.         $d = "";
  155.         $d = opendir($this->directory) or die($php_errormsg);
  156.         while(false!==($f=readdir($d)))
  157.     {
  158.           if(is_file("$this->directory/$f"))
  159.       {
  160.                 $title = $this->createTitle($f);
  161.                 $this->filearray[$f] = $title;
  162.           }
  163.         }
  164.         closedir($d);
  165.     }    
  166. //////////////////////////////////////////////////////////////////
  167. //private functions
  168. /////////////////////////////////////////////////////////////////
  169.     private function createTitle($title)
  170.   {
  171.         //strip extension
  172.         $title = substr($title,0,strrpos($title, "."));
  173.         //replace word separator
  174.         $title = str_replace($this->replacechar, " ", $title);
  175.         return $title;
  176.     }
  177. }//end class    
  178. ?>
My ThumbnailImage code is as :
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. //requires GD 2.0.1 or higher
  3. //note about gif
  4. class ThumbnailImage
  5. {
  6.     private $image;
  7.     //not applicable to gif
  8.     private $quality = 100;
  9.     private $mimetype;
  10.     private $imageproperties;
  11.     private $initialfilesize;
  12. ////////////////////////////////////////////////////////
  13. //constructor
  14. ////////////////////////////////////////////////////////
  15.     public function __construct($file, $thumbnailsize = 100)
  16.   {
  17.         //check path
  18.         is_file($file) or die ("File: $file doesn't exist.");
  19.         $this->initialfilesize = filesize($file);
  20.         $this->imageproperties = getimagesize($file) or die ("Incorrect file type.");
  21.         // new function image_type_to_mime_type
  22.         $this->mimetype = image_type_to_mime_type($this->imageproperties[2]);    
  23.         //create image
  24.         switch($this->imageproperties[2]){
  25.             case IMAGETYPE_JPEG:
  26.                 $this->image = imagecreatefromjpeg($file);    
  27.                 break;
  28.             case IMAGETYPE_GIF:    
  29.                 $this->image = imagecreatefromgif($file);
  30.                 break;
  31.             case IMAGETYPE_PNG:
  32.                 $this->image = imagecreatefrompng($file);
  33.                 break;
  34.             default:
  35.                 die("Couldn't create image.");
  36.         }
  37.         $this->createThumb($thumbnailsize);
  38.     }
  39. ////////////////////////////////////////////////////////
  40. //destructor
  41. ////////////////////////////////////////////////////////
  42.     public function __destruct()
  43.   {
  44.         if(isset($this->image))
  45.     {
  46.             imagedestroy($this->image);            
  47.         }
  48.     }
  49. ////////////////////////////////////////////////////////
  50. //public methods
  51. ////////////////////////////////////////////////////////
  52.     public function getImage()
  53.   {
  54.         header("Content-type: $this->mimetype");
  55.         switch($this->imageproperties[2])
  56.     {
  57.             case IMAGETYPE_JPEG:
  58.                 imagejpeg($this->image,"",$this->quality);
  59.                 break;
  60.             case IMAGETYPE_GIF:
  61.                 imagegif($this->image);
  62.                 break;
  63.             case IMAGETYPE_PNG:
  64.                 imagepng($this->image,"",$this->quality);
  65.                 break;
  66.             default:
  67.                 die("Couldn't create image.");
  68.         }
  69.     }
  70. ////////////////////////////////////////////////////////
  71.     public function getMimeType(){
  72.  
  73.         return $this->mimetype;
  74.     }
  75. ////////////////////////////////////////////////////////
  76.     public function getQuality()
  77.   {
  78.         $quality = null;
  79.         if($this->imageproperties[2] == IMAGETYPE_JPEG    || $this->imageproperties[2] == IMAGETYPE_PNG)
  80.     {
  81.             $quality = $this->quality;
  82.         }
  83.         return $quality;
  84.     }
  85. ////////////////////////////////////////////////////////
  86.     public function setQuality($quality)
  87.   {
  88.         if($quality > 100 || $quality  <  1)
  89.     {
  90.             $quality = 75;
  91.     }
  92.         if($this->imageproperties[2] == IMAGETYPE_JPEG || $this->imageproperties[2] == IMAGETYPE_PNG)
  93.     {
  94.             $this->quality = $quality;
  95.         }
  96.     }
  97. ////////////////////////////////////////////////////////
  98.     public function getInitialFileSize()
  99.   {    
  100.         return $this->initialfilesize;
  101.     }
  102. ////////////////////////////////////////////////////////
  103. //private methods
  104. ////////////////////////////////////////////////////////
  105.     private function createThumb($thumbnailsize)
  106.   {
  107.         //array elements
  108.         $srcW = $this->imageproperties[0];
  109.         $srcH = $this->imageproperties[1];
  110.         //only adjust if larger than reduction size
  111.         if($srcW >$thumbnailsize || $srcH > $thumbnailsize)
  112.     {
  113.             $reduction = $this->calculateReduction($thumbnailsize);
  114.             //get proportions
  115.           $desW = $srcW/$reduction;
  116.           $desH = $srcH/$reduction;                                
  117.             $copy = imagecreatetruecolor($desW, $desH);            
  118.             imagecopyresampled($copy,$this->image,0,0,0,0,$desW, $desH, $srcW, $srcH)
  119.                  or die ("Image copy failed.");            
  120.             //destroy original
  121.             imagedestroy($this->image);
  122.             $this->image = $copy;            
  123.         }
  124.     }
  125. ////////////////////////////////////////////////////////
  126.     private function calculateReduction($thumbnailsize)
  127.   {
  128.         //adjust
  129.         $srcW = $this->imageproperties[0];
  130.         $srcH = $this->imageproperties[1];
  131.       if($srcW < $srcH)
  132.     {
  133.           $reduction = round($srcH/$thumbnailsize);
  134.       }
  135.     else
  136.     {              
  137.           $reduction = round($srcW/$thumbnailsize);
  138.       }
  139.         return $reduction;
  140.     }
  141. }//end class
  142. ////////////////////////////////////////////////////////
  143. ?>
My Getthumb code is as :

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. //this file will be the src for an img tag
  3. require 'ThumbnailImage.php';
  4. $path = @$_GET["path"];
  5. $maxsize = @$_GET["size"];
  6. if(!isset($maxsize))
  7. {
  8.     $maxsize=100;
  9. }
  10. if(isset($path))
  11. {
  12.   $thumb = new ThumbNailImage($path, $maxsize);        
  13.   $thumb->getImage();
  14. }
  15. ?>
Please help! Thanks in advance!
Sep 14 '10 #1
1 3031
Markus
6,050 Recognized Expert Expert
So what is your question?
Sep 14 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

13
14500
by: TrintCSD | last post by:
How can I reset the collections within a foreach to be read as a change from within the foreach loop then restart the foreach after collections has been changed? foreach(string invoice in findListBox.listBox2.Items) { listBox2.Items count changed, restart this foreach } Thanks for any help.
5
2656
by: David C | last post by:
This is very strange. Say I have code like this. I am simply looping through a collection object in a foreach loop. Course course = new Course(); foreach(Student s in course.Students) { Console.WriteLine(s.StudentID); }
5
5044
by: Peter Lapic | last post by:
I have to create a image web service that when it receives an imageid parameter it will return a gif image from a file that has been stored on the server. The client will be an asp.net web page that calls the web service to render a vertical strip of images. After doing some research I am unable to find some vb.net code that can assist in what I want to achieve. The closest thing I found was
4
2249
by: Jack E Leonard | last post by:
I'm looping through the keys and values of a form submission using foreach($_POST as $key => $value) echo "$key = $value<br>"; No problems there. All works as expected. But seveal of the values are arrays and the echo comes out like: subjectone = Array subjecttwo = Array
1
2815
by: TSmith | last post by:
Hey Y'all, I haven't programmed in PHP in quite a while. Could anyone help me with a foreach loop in a nested array? I have a function which returns $stock (for an online pricing catalog). $stock is ( =Item, =Sale, ...) an array of column headers. $stock is ( =SL, =300, ...) an array of column headers to value for item $i
2
6854
by: Randy | last post by:
Hi, I have a small table - 2 columns, 5 rows. Col 1 is the key column and has integer values of 1 through 5. Column 2 is a varbinary(MAX) column and has jpg images loaded in it. What I want to is to bind a combobox to this table so that the combobox will display these these five images in its dropdown list and the user can then select any of them. Depending on which image is selected, the combobox will display the image and I will...
10
2964
by: fig000 | last post by:
HI, I'm new to generics. I've written a simple class to which I'm passing a generic list. I'm able to pass the list and even pass the type of the list so I can use it to traverse it. It's a generic list of business objects. I'm able to see that the type is the correct one in the debugger. However when I try to traverse the list using the type I can't compile. The same type variable I've verified as being passed
1
3036
by: djmeltdown | last post by:
I'm having trouble getting a foreach() loop to insert a record into a MySQL Database. Which I've never had any trouble before, it just seems quirky. I've tried the mysql_query statement without a preceeding variable as well. System information Server Apache/2.2.4 (Win32) DAV/2 mod_ssl/2.2.4 OpenSSL/0.9.8e mod_autoindex_color PHP/5.2.3 Time: 12/07/2007 01:20:06 PM PHP PHP Version: 5.2.3 Safe Mode activated: no PHP Memory...
3
2686
by: SM | last post by:
Hello, I have an array that holds images path of cd covers. The array looks like this: $cd = array( 589=>'sylver.jpg', 782=>'bigone.jpg', 158=>'dime.jpg' );
14
3006
anfetienne
by: anfetienne | last post by:
Hi, i went through a tutorial on how to display images stored with a directory and it came out good but i have a problem.....when i upload less than 5 files it displays the 1 image and then shows broken image placeholders. If i don't upload in sums of 5 then these broken image places holders keep showing, and instead of the images displaying row by row it goes by columns. Below is the code to display....can someone tell me where i've gone...
0
9685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9535
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10201
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10021
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9061
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7558
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6802
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5454
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4130
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.