title: php img src to php and database row?
body: <p>I've searched hi and low for an answer to my queston, I'm attempting to call a php file with a script to check file size and output an image based of a database table of a certain type. Would anyone be able to help?
  I'm getting a <code>undefined index for stocknr</code> when I run it even with <code>$row[stocknr]</code> as <code>$stocknr = $_GET['stocknr']</code>.</p>
  
  <pre><code>// assume connection
  $query = "SELECT year, brand, model, class, stocknr, price, status, pic FROM 
  stock WHERE class = 'ldv' ORDER BY brand ASC";
  // Perform Query
  $result = mysqli_query($con,$query);
  if (!$result) 
  {
  die("Connection Error: " . mysqli_connect_error());
  }
  // test array
  $product = array();
  while ($row = mysqli_fetch_array($result))
  {
  for($j = 1; $j &lt;= 30; $j++) {
  
      $product[$j]["model"] = "MODEL-$j";
      $product[$j]["pic"] = "PIC-$j";
      $product[$j]["price"] = "PRICE-$j";
  }
  // counter for cells
  $i = 1;
  // begin a table
  echo '&lt;table border="1"&gt;' . "\n";
  foreach($product as $row)
  // while($row = mysql_fetch_array($result)) 
  { 
      $title = $row['model'] ;
      $uppic = $row['pic'];
      $price = $row['price'];
      // for 1st, 6th, 11th etc record insert a tag for a new row
      if (($i == 1) or (($i - 1) % 4) == 0) {
  
          echo '&lt;tr&gt;' . "\n";
      }
      // insert a cell
      echo ("&lt;td width=150 align=center&gt;");
      echo ("&lt;a href=../imagesize.php?scode=$uppic&gt;&lt;img 
  src=images/'$uppic'.jpg border=0 alt=Item $title&lt;/a&gt;");
  // $row[stocknr]? 
      echo ("&lt;br&gt;&lt;a href=\"details.php?stocknr=$row[stocknr]\"&gt;
            &lt;span class=fs13&gt;$title&lt;/span&gt;&lt;/a&gt;");
      echo ("&lt;/td&gt;");
      echo ("&lt;tr height=150&gt;");
      echo ("&lt;a href=\"details.php?stocknr=$row[stocknr]\"&gt;
           &lt;span class=sapri&gt;$price&lt;/span&gt;&lt;/a&gt;");
      // for 5th, 10th, 15th etc record insert a tag for end of the row
      if ((($i) % 5) == 0) {
  
          echo '&lt;/tr&gt;';
      }
  
      // increment $i
      $i++;
   }
   }
   // filling row with empty cells 
  
   while(($i - 1) % 5 != 0) {
  
      // insert a blank cell
      echo '&lt;td&gt;&amp;nbsp;&lt;/td&gt;';
  
      // increment $i
      $i++;
  
      // for 5th, 10th, 15th etc record insert a tag for end of the row
      if (($i - 1) % 5 == 0) {
  
          echo '&lt;/tr&gt;';
      }
  }
  // end the table
  echo '&lt;/table&gt;';
  ?&gt;
  </code></pre>