/    Sign up×
Community /Pin to ProfileBookmark

php display mysqli results over 2 html divs

Hello:

I am having a brain fart on how to get this done and any ideas would greatly be appreciated. I am working on a in-house mailbox project and have my first problem. I am going to try and explain this a simple as possible as putting the words from my head to screen harder than I thought.

I have a page with 1 div called msgs_main. Inside of that div are 2 more, top one called msgs_msgs and the bottom called msgs_content. The msgs_msgs div contains a simple mysqli query displaying the records that correspond to the user. What I want/need is that when the user clicks one of the rows, the contents of the message are displayed in the msgs_content div.

I could provide the code, if it helps, but I am not really looking for answered code, but a process to learn from, like. “First, get a join and have all the records display in the msg_msgs div. Display them all to see that all the data is there. Later in production, remove the un-necessary fields from top div”. Then research …. etc

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@NogDogNov 09.2014 — You could do it with JavaScript by populating each message header in the first div with the message ID as part of the link. That link would then point to a separate PHP script that just serves up the message text. I would then wrap up each link in JavaScript to make it an AJAX call (if you use a JS framework like jQuery that's pretty simple), which on a successful response from the specific message script would display the message contents in the 2nd div.

Or you can keep it simpler by just putting logic into the main PHP script to look for a message ID in the request, and if there, get and display that message in the 2nd div, not using JavaScript at all for this. The only downside is this would be a full page reload -- but that's not a big deal if you're using good HTML techniques that allow all the CSS, JS, and images to be cached.

The last alternative would be to dump all the message texts into something that JavaScript on the page can use (probably a JSON object?), and do everything on the client side using JS. If there could be a lot of large messages (for undefined values of "a lot" and "large"), it might make page loads a bit sluggish.
×

Success!

Help @pepelepew1962 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.24,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...