OriginalSunny Posted April 19, 2006 Share Posted April 19, 2006 while($row = mysql_fetch_assoc($result)) { foreach($row as $field => $value) { if($field != "purchaseID") {[b] $items[$n][$field]=$value;[/b] if($field == "modelnum") { $sql_2 = "SELECT prodDesc FROM stock WHERE modelnum = '$row[modelnum]'"; $result2 = mysql_query($sql_2,$cxn) or die("sql_2: ".mysql_error($cxn)); $row = mysql_fetch_row($result2);[b] $items[$n]["name"]=$row[0]." ".$row[1];[/b] } } } $n++;}From what i can understand it is going through the loop for the total number of rows(in the value $result) and then if the field is not equal to purchaseID it goes through to the next bit and so on... I dont understand what is being stores in the arrays which are in bold. Please could someone tell me.Thanks. Quote Link to comment Share on other sites More sharing options...
poirot Posted April 19, 2006 Share Posted April 19, 2006 [!--quoteo(post=366389:date=Apr 19 2006, 12:35 PM:name=OriginalSunny)--][div class=\'quotetop\']QUOTE(OriginalSunny @ Apr 19 2006, 12:35 PM) [snapback]366389[/snapback][/div][div class=\'quotemain\'][!--quotec--]while($row = mysql_fetch_assoc($result)) { foreach($row as $field => $value) { if($field != "purchaseID") {[b] $items[$n][$field]=$value;[/b] if($field == "modelnum") { $sql_2 = "SELECT prodDesc FROM stock WHERE modelnum = '$row[modelnum]'"; $result2 = mysql_query($sql_2,$cxn) or die("sql_2: ".mysql_error($cxn)); $row = mysql_fetch_row($result2);[b] $items[$n]["name"]=$row[0]." ".$row[1];[/b] } } } $n++;}From what i can understand it is going through the loop for the total number of rows(in the value $result) and then if the field is not equal to purchaseID it goes through to the next bit and so on... I dont understand what is being stores in the arrays which are in bold. Please could someone tell me.Thanks.[/quote]Well, you would have an array named $items, something like this:[code]$items = array ( '0' => array ( 'field1' => 'value1', 'field2' => 'value2', 'field3' => 'value3', 'name' => 'Some Thing' ), '1' => array ( 'field1' => 'value1 (for another row)', 'field2' => 'value2', 'field3' => 'value3', 'name' => 'Some Thing Else' ),...[/code] Quote Link to comment Share on other sites More sharing options...
Barand Posted April 19, 2006 Share Posted April 19, 2006 this will show you what's in the items array[code]echo '<pre>', print_r ($items, true), '</pre>';[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.