[PHP] Whats the correct syntax for using query results in a new query

2009-03-03 Thread Terion Miller
I'm trying to use the AdminID that returns from query #1 in the WHERE
AdminID = AdminID from Query 1

$sql= SELECT WorkOrderID, CreatedDate, Location, WorkOrderName,
AdminID, FormName, Status, Notes, pod FROM `workorders` WHERE AdminID =
'.$row['AdminID'].' ;

that isn't working and the query 1 does return in this case 3 AdminID's so
I'm thinking it's just the .$row['AdminID'] part that is wrong
and I have tried some different things but am not sure the correct term for
what I'm trying to do so I can' t seem to google answers

Here is my query #1

  $query =  SELECT `UserName`, `AdminID` FROM admin
  WHERE   Retail1 =  'YES' ;

$result = mysql_query ($query) ;
//$row = mysql_fetch_array($result);
while ($row = mysql_fetch_row($result)){
for ($i=0; $imysql_num_fields($result); $i++)
echo $row[$i] .  ;

}
Above returns 3 AdminID ... I also tried using the While statement in my
second query to return the sets but nothing... yet the code isn't breaking,
just returning 0

Thanks
Terion

Happy Freecycling
Free the List !!
www.freecycle.org
Over Moderation of Freecycle List Prevents Post Timeliness.

Twitter?
http://twitter.com/terionmiller

Facebook:
a href=http://www.facebook.com/people/Terion-Miller/1542024891;
title=Terion Miller's Facebook profile target=_TOPimg src=
http://badge.facebook.com/badge/1542024891.237.919247960.png; border=0
alt=Terion Miller's Facebook profile/a
Joe DiMaggio  - Pair up in threes.


Re: [PHP] Whats the correct syntax for using query results in a new query

2009-03-03 Thread Ashley Sheridan
On Tue, 2009-03-03 at 14:09 -0600, Terion Miller wrote:
 I'm trying to use the AdminID that returns from query #1 in the WHERE
 AdminID = AdminID from Query 1
 
 $sql= SELECT WorkOrderID, CreatedDate, Location, WorkOrderName,
 AdminID, FormName, Status, Notes, pod FROM `workorders` WHERE AdminID =
 '.$row['AdminID'].' ;
 
 that isn't working and the query 1 does return in this case 3 AdminID's so
 I'm thinking it's just the .$row['AdminID'] part that is wrong
 and I have tried some different things but am not sure the correct term for
 what I'm trying to do so I can' t seem to google answers
 
 Here is my query #1
 
   $query =  SELECT `UserName`, `AdminID` FROM admin
   WHERE   Retail1 =  'YES' ;
 
 $result = mysql_query ($query) ;
 //$row = mysql_fetch_array($result);
 while ($row = mysql_fetch_row($result)){
 for ($i=0; $imysql_num_fields($result); $i++)
 echo $row[$i] .  ;
 
 }
 Above returns 3 AdminID ... I also tried using the While statement in my
 second query to return the sets but nothing... yet the code isn't breaking,
 just returning 0
 
 Thanks
 Terion
 
 Happy Freecycling
 Free the List !!
 www.freecycle.org
 Over Moderation of Freecycle List Prevents Post Timeliness.
 
 Twitter?
 http://twitter.com/terionmiller
 
 Facebook:
 a href=http://www.facebook.com/people/Terion-Miller/1542024891;
 title=Terion Miller's Facebook profile target=_TOPimg src=
 http://badge.facebook.com/badge/1542024891.237.919247960.png; border=0
 alt=Terion Miller's Facebook profile/a
 Joe DiMaggio  - Pair up in threes.
 

$query =  SELECT `UserName`, `AdminID` FROM admin WHERE   Retail1 =
'YES' ;

When you run this in phpMyAdmin, what is returned?

Ash
www.ashleysheridan.co.uk


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



Re: [PHP] Whats the correct syntax for using query results in a new query

2009-03-03 Thread Terion Miller
On Tue, Mar 3, 2009 at 2:20 PM, Ashley Sheridan 
a...@ashleysheridan.co.ukwrote:

 On Tue, 2009-03-03 at 14:09 -0600, Terion Miller wrote:
  I'm trying to use the AdminID that returns from query #1 in the WHERE
  AdminID = AdminID from Query 1
 
  $sql= SELECT WorkOrderID, CreatedDate, Location, WorkOrderName,
  AdminID, FormName, Status, Notes, pod FROM `workorders` WHERE AdminID =
  '.$row['AdminID'].' ;
 
  that isn't working and the query 1 does return in this case 3 AdminID's
 so
  I'm thinking it's just the .$row['AdminID'] part that is wrong
  and I have tried some different things but am not sure the correct term
 for
  what I'm trying to do so I can' t seem to google answers
 
  Here is my query #1
 
$query =  SELECT `UserName`, `AdminID` FROM admin
WHERE   Retail1 =  'YES' ;
 
  $result = mysql_query ($query) ;
  //$row = mysql_fetch_array($result);
  while ($row = mysql_fetch_row($result)){
  for ($i=0; $imysql_num_fields($result); $i++)
  echo $row[$i] .  ;
 
  }
  Above returns 3 AdminID ... I also tried using the While statement in my
  second query to return the sets but nothing... yet the code isn't
 breaking,
  just returning 0
 
 
 

 $query =  SELECT `UserName`, `AdminID` FROM admin WHERE   Retail1 =
 'YES' ;

 When you run this in phpMyAdmin, what is returned?

 Ash
 www.ashleysheridan.co.uk

 When I run the second query the one where the WHERE syntax is wrong if I
put it like this I still get one record:

SQL query: SELECT WorkOrderID, CreatedDate, Location, WorkOrderName, AdminID
, FormName,
STATUS , Notes, pod
FROM `workorders`
WHERE AdminID = '20'
AND '61'
AND '24'
LIMIT 0 , 30 this part keeps getting put in by phpMyAdmin

the first query works and returns the records it should... which are 3
usernames and 3 adminID


Re: [PHP] Whats the correct syntax for using query results in a new query

2009-03-03 Thread Dan Shirah

 I'm trying to use the AdminID that returns from query #1 in the WHERE
 AdminID = AdminID from Query 1


Okay, I think I understand what you are trying to do.

//query 1
$query1 =  SELECT UserName, AdminID FROM admin
 WHERE   Retail1 =  'YES';

$result1 = mysql_query ($query1) ;
while ($row1 = mysql_fetch_row($result1)){

$admin_id = $row1['AdminID'];

//query 2
$query2= SELECT WorkOrderID, CreatedDate, Location, WorkOrderName,
AdminID, FormName, Status, Notes, pod FROM workorders WHERE AdminID =
$admin_id;

$result2 = mysql_query ($query2) ;
$end_result = mysql_fetch_row($result2);
echo $end_result['WorkOrderID'];
echo $end_result['CreatedDate'];

}


Re: [PHP] Whats the correct syntax for using query results in a new query

2009-03-03 Thread Ashley Sheridan
On Tue, 2009-03-03 at 14:36 -0600, Terion Miller wrote:
 On Tue, Mar 3, 2009 at 2:20 PM, Ashley Sheridan 
 a...@ashleysheridan.co.ukwrote:
 
  On Tue, 2009-03-03 at 14:09 -0600, Terion Miller wrote:
   I'm trying to use the AdminID that returns from query #1 in the WHERE
   AdminID = AdminID from Query 1
  
   $sql= SELECT WorkOrderID, CreatedDate, Location, WorkOrderName,
   AdminID, FormName, Status, Notes, pod FROM `workorders` WHERE AdminID =
   '.$row['AdminID'].' ;
  
   that isn't working and the query 1 does return in this case 3 AdminID's
  so
   I'm thinking it's just the .$row['AdminID'] part that is wrong
   and I have tried some different things but am not sure the correct term
  for
   what I'm trying to do so I can' t seem to google answers
  
   Here is my query #1
  
 $query =  SELECT `UserName`, `AdminID` FROM admin
 WHERE   Retail1 =  'YES' ;
  
   $result = mysql_query ($query) ;
   //$row = mysql_fetch_array($result);
   while ($row = mysql_fetch_row($result)){
   for ($i=0; $imysql_num_fields($result); $i++)
   echo $row[$i] .  ;
  
   }
   Above returns 3 AdminID ... I also tried using the While statement in my
   second query to return the sets but nothing... yet the code isn't
  breaking,
   just returning 0
  
  
  
 
  $query =  SELECT `UserName`, `AdminID` FROM admin WHERE   Retail1 =
  'YES' ;
 
  When you run this in phpMyAdmin, what is returned?
 
  Ash
  www.ashleysheridan.co.uk
 
  When I run the second query the one where the WHERE syntax is wrong if I
 put it like this I still get one record:
 
 SQL query: SELECT WorkOrderID, CreatedDate, Location, WorkOrderName, AdminID
 , FormName,
 STATUS , Notes, pod
 FROM `workorders`
 WHERE AdminID = '20'
 AND '61'
 AND '24'
 LIMIT 0 , 30 this part keeps getting put in by phpMyAdmin
 
 the first query works and returns the records it should... which are 3
 usernames and 3 adminID
What about joining the queries?

SELECT admin.UserName, admin.AdminID, workorders.WorkOrderID,
workorders.CreateDate, workorders.Location, workorders.WorkOrderName,
workorders.FormName, workorders.STATUS, workorders.Notes, workorders.pod
FROM admin LEFT JOIN workorders ON (admin.AdminID = workorders.AdminID)
WHERE admin.Retail1 = 'yes'

I know it looks like a mess, but it should do the trick


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] Whats the correct syntax for using query results in a new query

2009-03-03 Thread Bastien Koert
On Tue, Mar 3, 2009 at 3:51 PM, Ashley Sheridan 
a...@ashleysheridan.co.ukwrote:

  On Tue, 2009-03-03 at 14:36 -0600, Terion Miller wrote:
  On Tue, Mar 3, 2009 at 2:20 PM, Ashley Sheridan 
 a...@ashleysheridan.co.ukwrote:
 
   On Tue, 2009-03-03 at 14:09 -0600, Terion Miller wrote:
I'm trying to use the AdminID that returns from query #1 in the WHERE
AdminID = AdminID from Query 1
   
$sql= SELECT WorkOrderID, CreatedDate, Location, WorkOrderName,
AdminID, FormName, Status, Notes, pod FROM `workorders` WHERE AdminID
 =
'.$row['AdminID'].' ;
   
that isn't working and the query 1 does return in this case 3
 AdminID's
   so
I'm thinking it's just the .$row['AdminID'] part that is wrong
and I have tried some different things but am not sure the correct
 term
   for
what I'm trying to do so I can' t seem to google answers
   
Here is my query #1
   
  $query =  SELECT `UserName`, `AdminID` FROM admin
  WHERE   Retail1 =  'YES' ;
   
$result = mysql_query ($query) ;
//$row = mysql_fetch_array($result);
while ($row = mysql_fetch_row($result)){
for ($i=0; $imysql_num_fields($result); $i++)
echo $row[$i] .  ;
   
}
Above returns 3 AdminID ... I also tried using the While statement in
 my
second query to return the sets but nothing... yet the code isn't
   breaking,
just returning 0
   
   
   
  
   $query =  SELECT `UserName`, `AdminID` FROM admin WHERE   Retail1 =
   'YES' ;
  
   When you run this in phpMyAdmin, what is returned?
  
   Ash
   www.ashleysheridan.co.uk
  
   When I run the second query the one where the WHERE syntax is wrong if
 I
  put it like this I still get one record:
 
  SQL query: SELECT WorkOrderID, CreatedDate, Location, WorkOrderName,
 AdminID
  , FormName,
  STATUS , Notes, pod
  FROM `workorders`
  WHERE AdminID = '20'
  AND '61'
  AND '24'
  LIMIT 0 , 30 this part keeps getting put in by phpMyAdmin
 
  the first query works and returns the records it should... which are 3
  usernames and 3 adminID
 What about joining the queries?

 SELECT admin.UserName, admin.AdminID, workorders.WorkOrderID,
 workorders.CreateDate, workorders.Location, workorders.WorkOrderName,
 workorders.FormName, workorders.STATUS, workorders.Notes, workorders.pod
 FROM admin LEFT JOIN workorders ON (admin.AdminID = workorders.AdminID)
 WHERE admin.Retail1 = 'yes'

 I know it looks like a mess, but it should do the trick


 Ash
 www.ashleysheridan.co.uk


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



incorrect syntax on your query

try

SQL query: SELECT WorkOrderID, CreatedDate, Location, WorkOrderName, AdminID
, FormName,
STATUS , Notes, pod
FROM `workorders`
WHERE AdminID in ( '20','61','24')

-- 

Bastien

Cat, the other other white meat


Re: [PHP] Whats the correct syntax for using query results in a new query

2009-03-03 Thread Ashley Sheridan
On Tue, 2009-03-03 at 15:54 -0500, Bastien Koert wrote:
 On Tue, Mar 3, 2009 at 3:51 PM, Ashley Sheridan 
 a...@ashleysheridan.co.ukwrote:
 
   On Tue, 2009-03-03 at 14:36 -0600, Terion Miller wrote:
   On Tue, Mar 3, 2009 at 2:20 PM, Ashley Sheridan 
  a...@ashleysheridan.co.ukwrote:
  
On Tue, 2009-03-03 at 14:09 -0600, Terion Miller wrote:
 I'm trying to use the AdminID that returns from query #1 in the WHERE
 AdminID = AdminID from Query 1

 $sql= SELECT WorkOrderID, CreatedDate, Location, WorkOrderName,
 AdminID, FormName, Status, Notes, pod FROM `workorders` WHERE AdminID
  =
 '.$row['AdminID'].' ;

 that isn't working and the query 1 does return in this case 3
  AdminID's
so
 I'm thinking it's just the .$row['AdminID'] part that is wrong
 and I have tried some different things but am not sure the correct
  term
for
 what I'm trying to do so I can' t seem to google answers

 Here is my query #1

   $query =  SELECT `UserName`, `AdminID` FROM admin
   WHERE   Retail1 =  'YES' ;

 $result = mysql_query ($query) ;
 //$row = mysql_fetch_array($result);
 while ($row = mysql_fetch_row($result)){
 for ($i=0; $imysql_num_fields($result); $i++)
 echo $row[$i] .  ;

 }
 Above returns 3 AdminID ... I also tried using the While statement in
  my
 second query to return the sets but nothing... yet the code isn't
breaking,
 just returning 0



   
$query =  SELECT `UserName`, `AdminID` FROM admin WHERE   Retail1 =
'YES' ;
   
When you run this in phpMyAdmin, what is returned?
   
Ash
www.ashleysheridan.co.uk
   
When I run the second query the one where the WHERE syntax is wrong if
  I
   put it like this I still get one record:
  
   SQL query: SELECT WorkOrderID, CreatedDate, Location, WorkOrderName,
  AdminID
   , FormName,
   STATUS , Notes, pod
   FROM `workorders`
   WHERE AdminID = '20'
   AND '61'
   AND '24'
   LIMIT 0 , 30 this part keeps getting put in by phpMyAdmin
  
   the first query works and returns the records it should... which are 3
   usernames and 3 adminID
  What about joining the queries?
 
  SELECT admin.UserName, admin.AdminID, workorders.WorkOrderID,
  workorders.CreateDate, workorders.Location, workorders.WorkOrderName,
  workorders.FormName, workorders.STATUS, workorders.Notes, workorders.pod
  FROM admin LEFT JOIN workorders ON (admin.AdminID = workorders.AdminID)
  WHERE admin.Retail1 = 'yes'
 
  I know it looks like a mess, but it should do the trick
 
 
  Ash
  www.ashleysheridan.co.uk
 
 
   --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
 incorrect syntax on your query
 
 try
 
 SQL query: SELECT WorkOrderID, CreatedDate, Location, WorkOrderName, AdminID
 , FormName,
 STATUS , Notes, pod
 FROM `workorders`
 WHERE AdminID in ( '20','61','24')
 
Where and what is the syntax error?


Ash
www.ashleysheridan.co.uk


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



Re: [PHP] Whats the correct syntax for using query results in a new query

2009-03-03 Thread Terion Miller
On Tue, Mar 3, 2009 at 2:51 PM, Ashley Sheridan 
a...@ashleysheridan.co.ukwrote:

 On Tue, 2009-03-03 at 14:36 -0600, Terion Miller wrote:
  On Tue, Mar 3, 2009 at 2:20 PM, Ashley Sheridan 
 a...@ashleysheridan.co.ukwrote:
 
   On Tue, 2009-03-03 at 14:09 -0600, Terion Miller wrote:
I'm trying to use the AdminID that returns from query #1 in the WHERE
AdminID = AdminID from Query 1
   
$sql= SELECT WorkOrderID, CreatedDate, Location, WorkOrderName,
AdminID, FormName, Status, Notes, pod FROM `workorders` WHERE AdminID
 =
'.$row['AdminID'].' ;
   
that isn't working and the query 1 does return in this case 3
 AdminID's
   so
I'm thinking it's just the .$row['AdminID'] part that is wrong
and I have tried some different things but am not sure the correct
 term
   for
what I'm trying to do so I can' t seem to google answers
   
Here is my query #1
   
  $query =  SELECT `UserName`, `AdminID` FROM admin
  WHERE   Retail1 =  'YES' ;
   
$result = mysql_query ($query) ;
//$row = mysql_fetch_array($result);
while ($row = mysql_fetch_row($result)){
for ($i=0; $imysql_num_fields($result); $i++)
echo $row[$i] .  ;
   
}
Above returns 3 AdminID ... I also tried using the While statement in
 my
second query to return the sets but nothing... yet the code isn't
   breaking,
just returning 0
   
   
   
  
   $query =  SELECT `UserName`, `AdminID` FROM admin WHERE   Retail1 =
   'YES' ;
  
   When you run this in phpMyAdmin, what is returned?
  
   Ash
   www.ashleysheridan.co.uk
  
   When I run the second query the one where the WHERE syntax is wrong if
 I
  put it like this I still get one record:
 
  SQL query: SELECT WorkOrderID, CreatedDate, Location, WorkOrderName,
 AdminID
  , FormName,
  STATUS , Notes, pod
  FROM `workorders`
  WHERE AdminID = '20'
  AND '61'
  AND '24'
  LIMIT 0 , 30 this part keeps getting put in by phpMyAdmin
 
  the first query works and returns the records it should... which are 3
  usernames and 3 adminID
 What about joining the queries?

 SELECT admin.UserName, admin.AdminID, workorders.WorkOrderID,
 workorders.CreateDate, workorders.Location, workorders.WorkOrderName,
 workorders.FormName, workorders.STATUS, workorders.Notes, workorders.pod
 FROM admin LEFT JOIN workorders ON (admin.AdminID = workorders.AdminID)
 WHERE admin.Retail1 = 'yes'

 I know it looks like a mess, but it should do the trick


 Ash
 www.ashleysheridan.co.uk
 The joined query works as far as returning the records now I just have to
 get them to display and I'm good to go, thanks guys!