Jump to content
Larry Ullman's Book Forums
electrum

Can Inline Html Content Be Sent To A Page With Header() ?

Recommended Posts

Hi there,

 

I have just finished going through the examples in the book. I really enjoyed working through it! I was particularly interested in the final example, when the view_print page is sent an image through the header() function from the show_image script. Is there any way to send inline html content within the header function? I am unsure of how to do this.

 

I picked up your marvellous book because my ISP provides a basic MySQL service. My hope is to use dreamweaver's built in popup balloons / mouseovers to show the dictionary definitions within a Mysql database applied to textual elements within web pages. it would be easy enough to span each word with a seperate id, but Id prefer to insert the balloon text from a php script on my isp's cgi server. (Having limited space there) Such areas crop up all over my site, where I would love to have the definitions pop up, but can't as yet.

 

I already have access to the database files, but I will trim them down a bit and probably format them to suit the task (once I have a method!!)

 

I was hoping to use dreamweavers built in "spry tooltip" As far as I can tell (I know no javascript) it provides a text area with which to fill the 'tooltip' and can be styled with css.

 

So, is there a wonderful "text" alternative for the <img src=".." /> tag? How would I write the header() functions? I would attempt to pass the db id parameters with a get method as in your example.

 

I managed to find the databases through phpBible.org (Strong's lexicons) They have a similar thing up and running with a click-to-appear window. Whilst simply adding this to my site would be easy enough, I would much rather the mouseovers. Of course, no effort means little challenge! And I would customise the content and layout of the output.. A good first project for me.

 

Were it only a few words here and there, I would hard code it in or put the whole set of pages on the cgi server.. That's still an option, But I would like to give this a try if it can be done.

 

I would greatly appreciate your help!

Share this post


Link to post
Share on other sites

The good news is that what you want to do is fairly straightforward. The bad news is that JS is required.

 

More precisely, you'll want to use Ajax to have JS query a MySQL DB via PHP asynchronously. I highly recommend Larry's Ajax book. Within the first couple of chapters, you could have all the information you need to do what you want.

 

I don't think you can send text via the header function though.

 

Look into JS and Ajax a bit more, and then let us know if you need more help.

Share this post


Link to post
Share on other sites

I'm not sure that I follow why you couldn't just use PHP to pull the data from the database and populate the text area directly, without Ajax or any magic.

Share this post


Link to post
Share on other sites

Hi there,

 

I will seriously think about purchasing Larry's ajax book!

 

I was hoping to be able to use php for querying the databases.. Each section of text (bible verse) will need to be pre-formatted with references (<span id=...>) for each word, to the particular definition of the original greek, from the database. These id's will be pre-generated and left in the page's html content (from an admin script).

 

The particular tooltips would be better generated on the fly, with the content formatted by php - (being the bulk of the data) querying the lexicon databases with the particular word's id.

 

I think perhaps the alternate purpose of phpbible.org's script, as a concordance for searching the text for a particular english word is better suited to Larry's comment. (though if you click on a word in a displayed verse you will get a new window with the lexicon definition - that is what I would like to implement as a tooltip)

 

I considered using php to build all the pages and tooltips from scratch before the page finishes loading using dreamweavers tooltip widget, however as the tooltip content would need to be in place from the server already, rather than at the moment the particular word (in whatever verse) was hovered over - fully prepared content would really bulk things up. Each tooltip would need many definitions, rather than just one and a function call / get method. (I was hoping to simply use a specific GET method with the lexicon id)

 

As there could be a couple of hundred such words on the page all requiring different tooltips (dictionary def'ns), I would much prefer using the "magic" to keep the source short.

 

Opening in a seperate window would speed things up, but using a popup balloon without the need to reload the page or open/close windows etc is my goal. (Otherwise I may just use the original phpbible script)

 

I managed to get a book out of the library on javascript - I will certainly look to see about using php asynchronously. (I think I've chosen far too thick a book on the subject, (and probably far too technical) so I will certainly keep an eye out for Larry's book!)

 

Thanks again!

Share this post


Link to post
Share on other sites

I think the easiest method would be to use <span title="your definition text here">word</span>. No need for javascript, you could do the whole thing in PHP with queries from the database for the words and its related definition. The title attribute will display as a "tool tip" when your cursor is over the <span>. You can't style the popup, though.

Share this post


Link to post
Share on other sites

Hi again,

 

Thamks Paul, I might go for that if I cant get the definitions to work in 'ccs styled' table form within the popup. I have reserved a copy of Larry's ajax book from my county library, I should have it within a couple of days.

 

I found I can do exactly what I would've liked by using <iframe src="http://.../scripts/lexicon.php?id=1234"></iframe> within Dreamweavers tooltip balloons. (And style with css)

 

Unfortuneately, <iframe> looks as if it is on its way out. Still, I am always up for a challenge, and the ajax idea is certainly more future-proof than using frames.

 

Since I will have had to learn a little javascript to fiddle with the tooltip script (so I don't have to repeat the iframe tags everywhere), I may as well settle down and make sure things are done to last, and learn something useful too. (I cant even remember the last time I visited a site with frames)

 

Thanks!

Share this post


Link to post
Share on other sites

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.   Paste as plain text instead

  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.

Loading...

×
×
  • Create New...