joquius Posted June 9, 2006 Share Posted June 9, 2006 Just found this code quite useful for using predefined php values out of mysql, while using java to prevent reloading the page. Works exceptionally well.An example for an x,y key multidimensional array export:example array value; $array[3][4] = "#f0f0f0"; <?function load_schemes (){ if ($schemes = mysql_query ("select distinct `scheme` from `colors` where 1")) { while ($scheme = mysql_result ($schemes, 0)) { $result = mysql_query ("select * from `colors` where `scheme` = '$scheme'"); while ($_result = mysql_fetch_array ($result)) { $array[$_result['y']][$_result['x']] = $_result['color']; } ?><script type="text/javascript">var array_<?=$scheme?> = new Array()</script><? foreach ($array as $y => $value) { ?><script type="text/javascript">array_<?=$scheme?>['<?=$y?>'] = new Array()</script><? foreach ($array as $x => $_value) { ?><script type="text/javascript">array_<?=$scheme?>['<?=$y?>']['<?=$x?>'] = "<?=$_value?>"</script><? } } } }}?> I use this for colouring specific cells in a table with a large number of cells when you don't want to reload the table for each change. Once you export these you can then just reload different color arrays as needed within a java script. Link to comment Share on other sites More sharing options...
justsomeguy Posted June 9, 2006 Share Posted June 9, 2006 Just a point to note, Java and Javascript are different and completely unrelated. You're using Javascript. Link to comment Share on other sites More sharing options...
joquius Posted June 11, 2006 Author Share Posted June 11, 2006 yes i'm actually well aquainted with these two. Link to comment Share on other sites More sharing options...
justsomeguy Posted June 11, 2006 Share Posted June 11, 2006 Well this is what you said: Just found this code quite useful for using predefined php values out of mysql, while using java to prevent reloading the page.But you don't have any applets. Link to comment Share on other sites More sharing options...
joquius Posted June 12, 2006 Author Share Posted June 12, 2006 yes, indeed I mean javascript and not java. My mistake. Purely javascript...no java. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now