Jump to content

Storing RS in Array


Fehrant

Recommended Posts

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?

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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?  ???

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.