Fehrant Posted December 7, 2007 Share Posted December 7, 2007 I have a pretty straightforward question. I have run into a case where I need to do all the PHP processing before injecting variables into the HTML code. This includes queries. I decided to store the result set into an array. The array will be multi-dimensional, and will have very long text, not to mention eventually it will have large amounts of data. Is this acceptable? Will the array do just fine? Quote Link to comment https://forums.phpfreaks.com/topic/80570-storing-rs-in-array/ Share on other sites More sharing options...
trq Posted December 7, 2007 Share Posted December 7, 2007 Is this acceptable? Will the array do just fine? It is plausable and definately doable, there may be better methods however. What exactly is your reasonaing behind the need to do all the PHP processing before injecting variables into the HTML code? Quote Link to comment https://forums.phpfreaks.com/topic/80570-storing-rs-in-array/#findComment-408565 Share on other sites More sharing options...
Fehrant Posted December 7, 2007 Author Share Posted December 7, 2007 Yeah, that's my concern. That my lack of knowledge has led me to an option that might not be the best, however doable it is. Let me tell you the scenario. Look at the forum for a moment. You see above the posts (that have obviously been populated by a loop of a posts table) a navigation bar. The navigation bar has been processed before the looping of posts. The bar contains not only the ids of the thread these posts belong to, but also the name, and for that particular thread, it has the id of the forum it belongs to, and the name. And I don't suppose the table that has the posts has any information on the forum the posts of the thread belongs to. I suppose I could do just a query and processing of the bar, then another query, and the looping of the posts but... it is my understanding one has to keep queries to a minimum. Was I clear? ??? Quote Link to comment https://forums.phpfreaks.com/topic/80570-storing-rs-in-array/#findComment-408572 Share on other sites More sharing options...
trq Posted December 7, 2007 Share Posted December 7, 2007 Was I clear? Not exactly, but it sounds like you may want to look into mysql JOINs. If your database is designed properly you should be able to get all related data within one swift query. Quote Link to comment https://forums.phpfreaks.com/topic/80570-storing-rs-in-array/#findComment-408575 Share on other sites More sharing options...
Fehrant Posted December 7, 2007 Author Share Posted December 7, 2007 Oh, I did. Believe me, I had an intricate SQL query to get all the informations from all the tables I need. Let me try to use some pseudo-code to depict my issue. [connection to db, and selection of table] [html, head, title, body, some divs] [navigation bar would go here] [looping of posts: while $row = mysql_fetch_array] And that's my issue. Hence I was thinking of storing all the stuff from $row in an array, and then I would be able to refer to them without having to worry about the pointer (or is it called head?) moving one row ahead. Umm... sorry if this is confusing. I have the knowledge to make it work anyway, but I want to do it efficiently. Quote Link to comment https://forums.phpfreaks.com/topic/80570-storing-rs-in-array/#findComment-408580 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.