PHP and JavaScript Array's
Posted: Fri Oct 22, 2004 4:17 pm
Oki, lets start:
I query the DB and get results:
QUERY:
select field1, field2, field3, field4 from table1 where I_decide_on_the_search_condition
then goes the while loop and mysql_fetch_array and
NOW I'M STUCK...
If I would do it just in PHP I would create variables and create a page inside the while loop.
BUT I want to complicate my and othee life's, and I want to transfer all results to JS table to enable client side sorting (script that dinamicaly sorts the contents of the table based on the array data)
Now - How would I transfer the data from php to JS array's
I tried JS in the while loop - but as it is client side - nothing good happened, and the only solution I found was to collect all the data into separate array's (each column is gathered into its own array) and then echo-ed them as a string to JS which then exploded it to single parts and rebuilt the original results by creating multidimensional array.
Is there any SIMPLER way of doing this - and if code is available, I would appreciate it.
Thanks Ahead.
I query the DB and get results:
QUERY:
select field1, field2, field3, field4 from table1 where I_decide_on_the_search_condition
then goes the while loop and mysql_fetch_array and
NOW I'M STUCK...
If I would do it just in PHP I would create variables and create a page inside the while loop.
BUT I want to complicate my and othee life's, and I want to transfer all results to JS table to enable client side sorting (script that dinamicaly sorts the contents of the table based on the array data)
Now - How would I transfer the data from php to JS array's
I tried JS in the while loop - but as it is client side - nothing good happened, and the only solution I found was to collect all the data into separate array's (each column is gathered into its own array) and then echo-ed them as a string to JS which then exploded it to single parts and rebuilt the original results by creating multidimensional array.
Is there any SIMPLER way of doing this - and if code is available, I would appreciate it.
Thanks Ahead.