Your first function is only going to return one row of 'checked=no' records. The second function will only return one column of the result.
What you want is a JOIN. You can do all of this with a single query. Without knowing the format of your tables exactly, I can't give you the syntax, though. Check the MySQL manual and read the chapter on JOINs. ---John Holmes... ----- Original Message ----- From: "Steve Jackson" <[EMAIL PROTECTED]> To: "PHP General" <[EMAIL PROTECTED]> Sent: Tuesday, November 05, 2002 9:50 AM Subject: [PHP] Help me learn! with an explanation of these two functions. > Can someone run over these functions I have written to explain if my > logic is correct. > I'm still new to PHP and am trying to get my head round it! > This first function is to collect a list of order numbers from my > database where checked = no. > Am I correct in assuming that the variable $orderid will be an array of > results returned? How can I check this? > > function get_live_orders() > { > $conn = db_connect(); > $query = "select orderid from email where checked='no'"; > $result = @mysql_query($query); > if(mysql_numrows($result)>0) > $orderid = @mysql_fetch_array($result); > return $orderid; > } > > This second function is to take these order numbers and compare them to > order numbers in a second table and return the result of that. So if > order number 100001 is in the first array from the above function and > there is a number 100001 in the second query result I want to take all > the data in that row and return it. > > function get_order_details() > { > $orderid = get_live_orders(); > $conn = db_connect(); > $query = "select * from orders where orderid='$orderid'"; > $result = @mysql_query($query); > if (!$result) > return false; > $result = mysql_result($result, 0, "orderid"); > return $result; > } > > I haven't actually run this yet but I'd like someone to explain to me > what these functions will do so I am not just copy pasting code and > hoping to get it right eventually! Probably I have written this wrong > anyway and would like help before I actually attempt to do what I am > after. > I'll look back on this tomorrow so any help will be greatly appreciated. > Kind regards, > Steve Jackson > Web Developer > Viola Systems Ltd. > http://www.violasystems.com > [EMAIL PROTECTED] > Mobile +358 50 343 5159 > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php