unable to display images from database via php array
<p>Learning php!</p>

<p>I have a sql database which contains a table called 'images' which stores image paths that users would upload. The problem I am having is pulling the image paths from the database to a PHP array, then using the paths to display the images on the screen as a , list item. However when I run the page nothing is displayed.</p>

<p>code for database connection:</p>

<pre><code>include('Database.php');

class Images extends Database{

private $_images = array();

public function __construct(){

  $conn = $this-&gt;create_connection('read');     
  $sql = "SELECT image_path FROM 'items' WHERE catagory='tshirt'";      
  $result = $conn-&gt;query($sql)or die(mysql_error());        
  while($paths = mysql_fetch_array($result)) {      
    $this-&gt;_images[] = $paths['catagory'];      
  }         
}

public function getItems() {        

  return $this-&gt;_images;   
}
</code></pre>

<p>code for the view:</p>

<pre><code>&lt;ul&gt;
&lt;?php
require ('../model/Images.php');
$imageArray = array();
$images = new Images();
$imageArray[] = $images-&gt;getItems();
foreach($ImageArray as $value){
        echo '&lt;li&gt;&lt;img src="'.$value.'"&gt;&lt;/li&gt;';
}   
?&gt;
&lt;/ul&gt;
</code></pre>

<p>I executed the SQL query using phpmyadmin, which query's correctly. Also I have simulated the database data by adding the image paths manually to test looping through array.</p>

<pre><code>private $_images = array('./images/tshirt1.jpg', etc, etc);
</code></pre>

<p>so I know the foreach loop and query work. The 'create_connection' function I have used before, connecting to the same database without any issues, I am a bit
stumped, but I think it may be connected to the mysql_fetch_array section?</p>

<p>Am I using the correct approach? or is there a better way to solve this issue?</p>

<p>Hope someone can point me in the right direction!</p>

<p>Thanks</p>
