title: Creating a list using data from MySQL database
body: <p>I'm trying to create a basic product list that takes data from the MySQL database and display on screen of the website. </p>
  
  <p>I currently have the following code but still needs some work, it currently only displays the name and category with an error message saying:Warning: printf(): Too few arguments in C:\xampp\htdocs\ICTDBS504\list items.php on line 41
  () ()</p>
  
  <p>I also need to add a photo in but I am unsure on how and where that goes in the code. Should the photo be apart of the html or saved on the database? and if on the database how does that get written into the php code</p>
  
  <pre><code>&lt;?php
      $mysqli = new mysqli("localhost", "root", "", "etrading");
  
      /* check connection */
      if ($mysqli-&gt;connect_errno) {
          printf("Connect failed: %s\n", $mysqli-&gt;connect_error);
          exit();
      }
  
      $query = "SELECT Name, Category, Price, Duration, Photo FROM item ORDER by ItemID LIMIT 3";
      $result = $mysqli-&gt;query($query);
  
      /* numeric array */
      $row = $result-&gt;fetch_array(MYSQLI_NUM);
      printf ("%s (%s)\n", $row[0], $row[1]);
  
      /* associative array */
      $row = $result-&gt;fetch_array(MYSQLI_ASSOC);
      printf ("%s (%s) (%s)\n", $row["Name"], $row["Category"]);
  
      /* associative and numeric array */
      $row = $result-&gt;fetch_array(MYSQLI_BOTH);
      printf ("%s (%s) (%s)\n", $row[0], $row["Price"], $row["Duration"]);
  
      /* free result set */
      $result-&gt;free();
  
      /* close connection */
      $mysqli-&gt;close();
  ?&gt;
  </code></pre>