Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

bind-address mysql multiple, sanibleone xxxx, ftp://192.168.100.100/, www.xxxcon, which comes first ob_start or session, wwwxxx/58/2010, xxxxdup, xxxxdup, mailx informatii, should producers of software-based services, such as atms, be held liable for economic injuries suffered when their systems fail?

Links

XODOX
Impressum

#1: Duplicate table results

Posted on 2011-07-06 07:13:45 by Karl DeSaulniers

--Apple-Mail-1-909544130
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=US-ASCII;
delsp=yes;
format=flowed

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.


UPLOADS TABLE
fileID
Username
OrderID
UpID
fileName
timestamp

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:::

(database.php)

/**
* 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?

(session.php)

$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:

TIA

Karl DeSaulniers
Design Drumm
http://designdrumm.com


--Apple-Mail-1-909544130--

Report this message

#2: Re: Duplicate table results

Posted on 2011-07-06 10:54:24 by Karl DeSaulniers

I love the teddy bear effect...

Corrected Code::: (or at least it works now :)
(database.php)

/**
* getFiles - Returns all uploaded images for a print order. F
* If query fails, NULL is returned.
*/
function getFiles($username, $fileID){ //to just get the current
upload files
$q = "SELECT fileName FROM ".UPLOADS." WHERE username =
'".mysql_real_escape_string($username)."' AND (OrderID =
'".mysql_real_escape_string($fileID)."' OR UpID =
'".mysql_real_escape_string($fileID)."') ORDER BY fileID ASC";
$result = $this->query($q);
if(!$result || (mysql_numrows($result) < 1)){
return NULL;
}
/* Return result array */
$dbarray = array();
while($row = mysql_fetch_array($result)) {
array_push($dbarray, $row['fileName']);
}
return $dbarray;
}

(session.php)

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

Best,
Karl

On Jul 6, 2011, at 12:13 AM, Karl DeSaulniers wrote:

> 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.
>
>
> UPLOADS TABLE
> fileID
> Username
> OrderID
> UpID
> fileName
> timestamp
>
> 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:::
>
> (database.php)
>
> /**
> * 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?
>
> (session.php)
>
> $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:
>
> TIA
>
> Karl DeSaulniers
> Design Drumm
> http://designdrumm.com
>

Karl DeSaulniers
Design Drumm
http://designdrumm.com


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Report this message

#3: Re: Duplicate table results

Posted on 2011-07-06 22:23:41 by Karl DeSaulniers

--Apple-Mail-1-964139773
Content-Transfer-Encoding: 7bit
Content-Type: text/plain;
charset=US-ASCII;
delsp=yes;
format=flowed

Hi Barry,

$dbarray = array();
while($row = mysql_fetch_array($result)) {
array_push($dbarray, $row['fileName']);
}

That was the difference.
The while($row =

Best,
Karl


On Jul 6, 2011, at 12:41 PM, Barry Stear wrote:

> Hmmm i didn't even see a different in the code between the first
> post and second. Guess I missed something. Glad you got it working
> though!
>
> On Wed, Jul 6, 2011 at 1:54 AM, Karl DeSaulniers
> <karl@designdrumm.com> wrote:
> I love the teddy bear effect...
>
> Corrected Code::: (or at least it works now :)
> (database.php)
>
> /**
> * getFiles - Returns all uploaded images for a print order. F
>
> * If query fails, NULL is returned.
> */
> function getFiles($username, $fileID){ //to just get the current
> upload files
> $q = "SELECT fileName FROM ".UPLOADS." WHERE username =
> '".mysql_real_escape_string($username)."' AND (OrderID =
> '".mysql_real_escape_string($fileID)."' OR UpID =
> '".mysql_real_escape_string($fileID)."') ORDER BY fileID ASC";
>
> $result = $this->query($q);
> if(!$result || (mysql_numrows($result) < 1)){
> return NULL;
> }
> /* Return result array */
> $dbarray = array();
> while($row = mysql_fetch_array($result)) {
> array_push($dbarray, $row['fileName']);
> }
> return $dbarray;
>
> }
>
> (session.php)
>
> $fileInfo = array();
> $fileInfo = $database->getFiles($subusername, $subUpID);
> $subfileName1 = $fileInfo[0];
> $subfileName2 = $fileInfo[1];
> $subfileName3 = $fileInfo[2];
> $subfileName4 = $fileInfo[3];
>
> Best,
> Karl
>
>
> On Jul 6, 2011, at 12:13 AM, Karl DeSaulniers wrote:
>
> 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.
>
>
> UPLOADS TABLE
> fileID
> Username
> OrderID
> UpID
> fileName
> timestamp
>
> 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:::
>
> (database.php)
>
> /**
> * 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?
>
> (session.php)
>
> $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:
>
> TIA
>
> Karl DeSaulniers
> Design Drumm
> http://designdrumm.com
>
>
> Karl DeSaulniers
> Design Drumm
> http://designdrumm.com
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
>
> --
> <a href="http://www.c28.com/?adid=st&iid=19467">
> <img src="http://www.c28.com/images/banner_88x31.gif" border="0"
> width="88" height="31"></a>

Karl DeSaulniers
Design Drumm
http://designdrumm.com


--Apple-Mail-1-964139773--

Report this message