Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

An SQL statement inside a while loop?

Status
Not open for further replies.

romerz

IS-IT--Management
Jul 19, 2006
29
GB
Is this possible?

Im recieved errors each time I try.

Code:
$sql = "SELECT * FROM WS_Orders WHERE ws_john2_number2=$order_no";
&reportError("Unable to open Orders Table : " . $DB->Error()) if ($DB->Sql($sql));
 while ($DB->FetchRow())
  {

%row = $DB->DataHash();

$order_orderdate = $row{'orderDate'};
$order_shipvia = $row{'ws_john2_text4'};
$order_terms = $row{'ws_john2_text5'};

$order_quantity = $row{'Line_Quantity'};
$order_garmentcode = $row{'ws_john2_text1'};
$order_colour = $row{'county'};
$order_xs = $row{'XS'};
$order_s = $row{'S'};
$order_m = $row{'M'};
$order_l = $row{'L'};
$order_xl = $row{'XL'};
$order_xxl = $row{'XXL'};
$order_xxxl = $row{'XXXL'};

$sql = "SELECT * FROM Garments WHERE garmentCode=$order_garmentcode";
&reportError("Unable to open Orders Table : " . $DB->Error()) if ($DB->Sql($sql));
  
$DB->FetchRow();
%row2 = $DB->DataHash();

$order_origin = $row2{'CJC_Kelkoo_fabric'};


}

Is what im trying to do -
 
You might be able to do it if you create a second statement handle. The first one is halfway through a cursor select just now.

Alternatively, you can use fetchall_arrayref() to get all the rows back in an array at once, and then work your way through them.

Or more simply, just join the two tables in the original query.

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top