PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi guys... today I came up with this challenge, and after a few hours I couldnt come up with an answer... So I hope someone can shed some light.
I am populating a <select> field with javascript going through a for loop for someArray that holds the values to be populates. In turn, this javascript array variable was populated by php reading from a mysql database... like this.. while(query stuff){<option>mysql values</option>}. No problem until here.
In the mysql database i have 2 tables: clients and shipping_instructions. So here, one client have have many shipping instructions.
I am already populating a javascript called clientsArray with the data from the mysql query. Now I need to dynamically create and populate one a javascript array for each client so that it holds all the shipping instruction values for that client... like this...
[syntax="javascript"]ClientOneArray = new Array("454rr54r", rr4r544r", 6y7y6yy7");
ClientTwoArray = new Array("454rr54r", rr4r544r", 6y7y6yy7");
ClientThreeArray = new Array("454rr54r", rr4r544r", 6y7y6yy7");
The weird looking values are fictional shipping instruction numbers that exist for that client.
How would I set up the mysql query to populate those values for every client.
NOTE - Obviously in the shipping_instructions table each record has the client id so thats how I join the tables
I would really appreciate any input on this... One million thanks!
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Are you needing help with the query? Or how to join tables? Or writing the results into a javascript array?
What have you tried, and what were the results?
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Hi! Sorry about that... since it wasnt really code... just some pseudo code i came up with.
I am needing help with the query and the while loop that will dynamically create those javascript arrays... You see, the problem is that I am only getting ONE shipping_instruction per client, when in fact each client has numerous shipping instructions.
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Last edited by devendra-m on Tue Dec 04, 2007 12:38 am, edited 1 time in total.
hmmm... Is $n the number of shippings instructions for all clients, which could be thousands, or the just the number of shipping instructions for one client?
The thing is getting all the shipping_instructions for one customer and their could be hundreds of customers. So php has to echo hundreds of javascript arrays each containing all the shipping instructions for each client. Then name of these created arrays should be for example