Jump to content

E_Rider

New Members
  • Posts

    6
  • Joined

  • Last visited

E_Rider's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks for the help the final solution seems to be mysqli_fetch_all($result , MYSQLI_ASSOC) "is the type". I have not tested this fully yet but the print_r call seems fine.
  2. I see why I was getting double arrays from the fetch and according to 3schools , wich I know to be wrong at times, fetch calls an associative array. Got to stop relying on 3schools to be correct and read the right manual.
  3. I am begining to see this and what I am trying to do is insert a delimiter in the middle of the mysqli_fech_array($result) so I can split it between two sections of a page. ie: split the $result so it can be called like $result[0] and $result[1]. I am hesitant to sat it cannot be done , but see I am doing it the wrong way.
  4. Is the fact that the $result is a multidimensional array causing this. I tested the base code from php.net and I am getting it to work. $input_array = array('a', 'b', 'c', 'd', 'e'); print_r(array_chunk($input_array, 1)); print_r(array_chunk($input_array, 2, true));
  5. I have cut this down and get each row but no new keys. if (!$result=mysqli_query($con,$sql)) { die('Could not get data: ' . mysqli_error($sql)); } echo "result_count".count($result)."<br/>"; while( $row=mysqli_fetch_array($result) ) { echo "row_count".count($row)."<br/>"; $rowt = array_chunk( $row, 1); print_r($rowt); echo "rowt_count".count($rowt)."<br/>"; echo "<br/><br/>"; } and this is output result_count1 row_count2 Array ( [0] => Array ( [0] => Acton ) [1] => Array ( [0] => Acton ) ) rowt_count2 row_count2 Array ( [0] => Array ( [0] => Alfred ) [1] => Array ( [0] => Alfred ) ) rowt_count2 row_count2 Array ( [0] => Array ( [0] => Bar Mills ) [1] => Array ( [0] => Bar Mills ) ) rowt_count2 row_count2 Array ( [0] => Array ( [0] => Berwick ) [1] => Array ( [0] => Berwick ) ) rowt_count2 row_count2 Array ( [0] => Array ( [0] => Biddeford ) [1] => Array ( [0] => Biddeford ) ) rowt_count2 row_count2 Array ( [0] => Array ( [0] => Buxton ) [1] => Array ( [0] => Buxton ) ) rowt_count2 row_count2 Array ( [0] => Array ( [0] => Cape Neddick ) [1] => Array ( [0] => Cape Neddick ) ) rowt_count2 row_count2 Array ( [0] => Array ( [0] => Cape Porpoise ) [1] => Array ( [0] => Cape Porpoise ) ) rowt_count2 row_count2 Array ( [0] => Array ( [0] => Cornish ) [1] => Array ( [0] => Cornish ) ) rowt_count2 row_count2 Array ( [0] => Array ( [0] => East Parsonsfield ) [1] => Array ( [0] => East Parsonsfield ) ) rowt_count2 row_count2 Array ( [0] => Array ( [0] => East Waterboro ) [1] => Array ( [0] => East Waterboro ) ) rowt_count2 row_count2 Array ( [0] => Array ( [0] => Eliot ) [1] => Array ( [0] => Eliot ) ) rowt_count2 row_count2 Array ( [0] => Array ( [0] => Hollis Center ) [1] => Array ( [0] => Hollis Center ) ) rowt_count2 row_count2 Array ( [0] => Array ( [0] => Kennebunk ) [1] => Array ( [0] => Kennebunk ) ) rowt_count2 row_count2 Array ( [0] => Array ( [0] => Kennebunkport ) [1] => Array ( [0] => Kennebunkport ) ) rowt_count2 row_count2 Array ( [0] => Array ( [0] => Kittery ) [1] => Array ( [0] => Kittery ) ) rowt_count2 row_count2 Array ( [0] => Array ( [0] => Kittery Point ) [1] => Array ( [0] => Kittery Point ) ) rowt_count2 row_count2 Array ( [0] => Array ( [0] => Lebanon ) [1] => Array ( [0] => Lebanon ) ) rowt_count2 row_count2 Array ( [0] => Array ( [0] => Limerick ) [1] => Array ( [0] => Limerick ) ) rowt_count2 row_count2 Array ( [0] => Array ( [0] => Limington ) [1] => Array ( [0] => Limington ) ) rowt_count2 row_count2 Array ( [0] => Array ( [0] => Moody ) [1] => Array ( [0] => Moody ) ) rowt_count2 row_count2 Array ( [0] => Array ( [0] => Newfield ) [1] => Array ( [0] => Newfield ) ) rowt_count2 row_count2 Array ( [0] => Array ( [0] => North Berwick ) [1] => Array ( [0] => North Berwick ) ) rowt_count2 row_count2 Array ( [0] => Array ( [0] => North Waterboro ) [1] => Array ( [0] => North Waterboro ) ) rowt_count2 row_count2 Array ( [0] => Array ( [0] => Ogunquit ) [1] => Array ( [0] => Ogunquit ) ) rowt_count2 row_count2 Array ( [0] => Array ( [0] => Old Orchard Beach ) [1] => Array ( [0] => Old Orchard Beach ) ) rowt_count2 row_count2 Array ( [0] => Array ( [0] => Parsonsfield ) [1] => Array ( [0] => Parsonsfield ) ) rowt_count2 row_count2 Array ( [0] => Array ( [0] => Saco ) [1] => Array ( [0] => Saco ) ) rowt_count2 row_count2 Array ( [0] => Array ( [0] => Sanford ) [1] => Array ( [0] => Sanford ) ) rowt_count2 row_count2 Array ( [0] => Array ( [0] => Shapleigh ) [1] => Array ( [0] => Shapleigh ) ) rowt_count2 row_count2 Array ( [0] => Array ( [0] => South Berwick ) [1] => Array ( [0] => South Berwick ) ) rowt_count2 row_count2 Array ( [0] => Array ( [0] => Springvale ) [1] => Array ( [0] => Springvale ) ) rowt_count2 row_count2 Array ( [0] => Array ( [0] => Waterboro ) [1] => Array ( [0] => Waterboro ) ) rowt_count2 row_count2 Array ( [0] => Array ( [0] => Wells ) [1] => Array ( [0] => Wells ) ) rowt_count2 row_count2 Array ( [0] => Array ( [0] => West Kennebunk ) [1] => Array ( [0] => West Kennebunk ) ) rowt_count2 row_count2 Array ( [0] => Array ( [0] => West Newfield ) [1] => Array ( [0] => West Newfield ) ) rowt_count2 row_count2 Array ( [0] => Array ( [0] => York ) [1] => Array ( [0] => York ) ) rowt_count2 and is expected but with new keys and less base arrays for lack of a better term.
  6. Hi, I am trying to split an array with array_chunk and having no luck. I can call the array, display the array, but not as two or more just not working as I understand it . I am pulling the array from MYSQL and have used count() to count arrays to debug this problem but get strange results. mysqli_query returns a value of one as expected, and this is where things get strange as mysqli_fetch_array variable counts as two before I even change or try to chunk, and chunk always returns two and will echo the whole array not chunks $array[0] echos but $array[1] is null. I am either trying to do something that cannot be done or my understanding is wrong. I have read the documentation over and over and anything else I could find with no luck. Any help would be appreciated.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.