paul2463 Posted June 19, 2006 Share Posted June 19, 2006 Hello,I am trying to get information from a sequel query and place it into 2 different arrays based on a test. I am pulling two values from the table valueA and valueB, if valueB is a certain number then valueA gets written to one new array and if the test fails then it is written to the other new array. here is the code:-<?php//create new variable arrays$arr1 = array();$arr2 = array();// connect to database , create and execute query$query = 'SELECT valueA, valueB FROM table';$result = mysql_query($query) or die ('Error in query: $query. ' . mysql_error());// check if records were returnedif (mysql_num_rows($result) > 0) { //iterate over record set [!--coloro:#FF0000--][span style=\"color:#FF0000\"][!--/coloro--]while($row = mysql_fetch_row($result)) { if ($row['valueB' == '1') { $arr1[] = $row['valueA']; [!--coloro:#000000--][span style=\"color:#000000\"][!--/coloro--]//will this bit work??[!--colorc--][/span][!--/colorc--] } else { $arr2[] = $row['valueA']; } }[!--colorc--][/span][!--/colorc--]}else{ // print error message echo 'No rows found!';}// close connection to MySQL servermysql_close($connection);?>It seems to run ok and places something into the relevant arrays but when I try and view whats in the arrays it tells me the block numbers of the arrays but the value is blank, as though it has placed a NULL value in there....I am now confused..thanks in advancevalueA is date object valueB is a number so what I am expecting is two arrays, both with dates in them, one corresponding to a row value of ones and the other to a row value of anything else. Quote Link to comment Share on other sites More sharing options...
AV1611 Posted June 19, 2006 Share Posted June 19, 2006 Add this to the end of your script and see what you get[code]print_r($arr1);echo "<br/><br/>";print_r($arr2);[/code] Quote Link to comment Share on other sites More sharing options...
paul2463 Posted June 20, 2006 Author Share Posted June 20, 2006 thanks for the help, I figured out my problem and it was tipping urror on my behalf, when you initialise a variable called "adate" and then try and refernece a variable called "aDate" it doesnt seem to work. how daft can one person be???(rhetorical question - no actual answer required) 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.