Duplicate table results

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Hello All,
I am wondering if you can help untie the knot in my head.
I have a table that stores the reference to an uploaded file on an order form.
Each upload has an upload ID as well as an Order ID
So say I upload 4 files on this form for an order.
All the files are getting uploaded correctly and the info is getting into the database correctly.
My problem is reading that info back out.


There can be multiple rows that have the same Upload ID and Order ID.
So I am trying to get each of the fileName(s) from each row according to the username and F_ID (F_ID can be the Upload ID or Order ID)

My Code:::


    * getFiles - Returns all uploaded images for a print order.
    * If query fails, NULL is returned.
   function getFiles($username, $F_ID){
$q = "SELECT * FROM ".UPLOADS." WHERE username = '".mysql_real_escape_string($username)."' AND (OrderID = '".mysql_real_escape_string($F_ID)."' OR UpID = '".mysql_real_escape_string($F_ID)."') ORDER BY fileID ASC";
      $result = $this->query($q);
      if(!$result || (mysql_numrows($result) < 1)){
         return NULL;
      /* Return result array */
      $dbarray = mysql_fetch_array($result);
      return $dbarray;

I am also trying to put the results into a multidimensional array, but
It only returns the first row though. What am I missing/doing wrong?


$fileInfo = array();
$fileInfo[] = $database->getFiles($subusername, $subUpID);
$subfileName1 = $fileInfo[0]['fileName'];
$subfileName2 = $fileInfo[1]['fileName'];
$subfileName3 = $fileInfo[2]['fileName'];
$subfileName4 = $fileInfo[3]['fileName'];

The following prints out:

Upload ID: UKcwbelR
File Name 1:3534.eps
File Name 2:
File Name 3:
File Name 4:


Karl DeSaulniers
Design Drumm

[PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Plagiarism Notes]     [Postgresql]     [Yosemite News]

Powered by Linux