Weedpacket, if i am not mistaken you are getting rows of data stored in an array. I am picking 1 value from $row array by key looping it and getting back an array of tables column. Do the same for 2nd tables then I merge them together into new array.
Once merged I start over on the next column.
I use mysql_data_seek(); to reset the pointer.
array_shift(); to drop the first item in the array 1 ++ because for some reason after the pointer moves from 0 to 1 the first element in my multidimentional array is empty so I trim it.
i did know that I get both key and assoc by using mysql_fetch_array but i needed the key. I use print_r() to test and make sure I get the correct data stored in my array.
then i searched the manual for functions that gave me the exact arrays I wanted to see.
this UNION SELECT is interesting...
ex.
SELECT date
FROM tbl1
UNION SELECT date
FROM tbl2
ORDER BY date DESC
I am not sure if that is correct syntax I will look into it tomorrow and will test it in console but the whole idea is that these tables are not related, but need to get 5 records from each table and sort them by date.
result:
<?php
/*
Array
(
[0] => Array
(
[0] => 59
[1] => 52
[2] => 51
[3] => 46
[4] => 45
[5] => 26
[6] => 25
[7] => 24
)
[1] => Array
(
[0] => 1269309124
[1] => 1268917574
[2] => 1269003974
[3] => 1268920407
[4] => 1268573783
[5] => 1269306769
[6] => 1269306769
[7] => 1269306769
)
[2] => Array
(
[0] => Sell Short
[1] => Buy Long
[2] => Sell Short
[3] => Sell Short
[4] => Sell Short
[5] => NULL
[6] => NULL
[7] => NULL
)
[3] => Array
(
[0] => AUD/USD
[1] => EUR/USD
[2] => USD/XAU
[3] => NZD/USD
[4] => AUD/USD
[5] => NULL
[6] => NULL
[7] => NULL
)
[4] => Array
(
[0] => no comment
[1] => no comment
[2] => no comment
[3] => Short term trade as Kiwi still strong to upside on rate differential
[4] => first target .9123 if breached looking for .9070
[5] => --GOLD upda
[6] => ... the euro/$ a
[7] => ... Friday
)
[5] => Array
(
[0] => .9165
[1] => 1.352
[2] => 1123.5
[3] => .7146
[4] => .9169
[5] => NULL
[6] => NULL
[7] => NULL
)
[6] => Array
(
[0] => .9085
[1] => 1.3545
[2] => 1103.
[3] => .7115
[4] => .9123
[5] => NULL
[6] => NULL
[7] => NULL
)
)
*/
// i will omit the NULL values by using if in the marquee, btw these are unsorted
?>
P.S. btw because of your post I was able to get rid of 3 lines of code the row=mysql_fetch_array(); x2 and do {} into just while made me loose the empty array elements I was getting at beginning of my arrays + i did not need to use array_shift(); function anymore but still I know it now hehe 🙂 thx and now If I can do it one query I can probably simplify even more I was thinking of like if this then use this query but i cant think of it how i can specify to use this then switch to other, maybe use the switch(){case break }