Results 1 to 3 of 3
Oct 4, 2012, 06:17 #1
- Join Date
- Oct 2012
- 0 Post(s)
- 0 Thread(s)
Tried everything - simply can't echo array values, just keep getting 'Array' instead.
I've spent the best part of a week trying to get this to work, and scoured the Internet for a solution, and got nowhere, so I'm now desperately hoping someone here can save the day!
What I've done is use mysqli_multi_query to SELECT three records from two different MySQL tables. Then I've combined the two outputs $output1 and $output2 into one array called $final, by using array_merge.
Everything works fine up to that point.
The last step is to display the contents of the $final array, but nothing I've tried works, every variation of code I've tried just displays the word Array instead of the actual value. Yet I know the values are sitting in the array, through checking the output of the print_r function (as below).
The only suggestion I found on Google that looked like it might work, was to assign the value of each array element to a string variable first, and then echo that ... but all that did was assign the value Array to the string ... again!
I'm completely stumped by this, so any ideas on how to output the actual values would be vastly appreciated! The relevent section of code is below (everything up to this point works fine, just this final step is the unsolvable problem for me).
From what I've read, the blank line in the output below is due to a gremlin with PHP's mysqli_multi_query, that generates an unwanted extra record.
Array (  => blue dalek  => (reviewer) )
Array (  => bluemoon  => (reviewer) )
Array (  => bubbleboy  => (reviewer) )
Array (  => beatles IV  => (album) )
Array (  => blue aeroplanes  => (album) )
Array (  => bluemoon  => (album) )
Not sure if it's relevent, but the background to this is that it's part of an Autocomplete Search function, which involves jQuery (that's why all the records begin with 'b', to test Autocomplete). Normally, Autocomplete can only query one table, so what I've done is use mySQLi's multi-query function to query two tables, then merged the two results into one array, then applied Autocomplete to that ... it's working fine, except I don't see the values in my search results, just this darned Array! Maybe I broke jQuery somehow ...?