stuck combining while loops
Posted: Thu Mar 26, 2009 3:55 pm
Hi all, basically what I am doing here is creating a while loop with a SQL statement that needs to populate a variable. after the while loop completes and my data bas populated the variable created in the while loop I need to pass that data into an additional select statement that loops again. I cant seem to figure out how to do this and Im sure there is an easier way.
I think that my logic is sound, but it is still not working. if anyone knows of an easier way to do this please let me know Ive been banging my head for the past couple hours trying to figure it out. Thanks!
Code: Select all
$query = "SELECT nid FROM ec_transaction_product WHERE txnid =".$txn->txnid;
$query2 = "SELECT body FROM node_revisions WHERE nid =".$noder;
$result = mysql_query($query) or die ("Error in query: $query. ".mysql_error());
if (mysql_num_rows($result) > 0) {
// yes
// print them one after another
//begin while loop
while($row = mysql_fetch_assoc($result)) {
$noder = $row[nid];
print $noder;
}
}
$query2 = "SELECT body FROM node_revisions WHERE nid =".$noder;
$result = mysql_query($query2) or die ("Error in query: $query. ".mysql_error());
if (mysql_num_rows($results) > 0) {
// yes
// print them one after another
//begin while loop
while($row = mysql_fetch_assoc($results)) {
$description = $row[body];
}
}
mysql_free_result($result);
mysql_free_result($results);I think that my logic is sound, but it is still not working. if anyone knows of an easier way to do this please let me know Ive been banging my head for the past couple hours trying to figure it out. Thanks!