Jump to content

How to import text from one page to another according to choice?


oli22

Recommended Posts

sbueq9.jpg

 

How to get text from chosen div on page descriptions.php and display it on play_video.php?

I have text in a paragraph, in a div. 

Displayed text will change every time according to  user's choice .

 

 

Thanks

 

 

[attachment deleted by admin]

Link to comment
Share on other sites

I simply have text in regular html paragraphs within divs on the descriptions.php page,  nothing stored anywhere.

 

I was imagining there might be a simple solution like putting the descriptions.php text sections in php tags and "calling them" from the video_play.php page with some kind of a"Get" or similar method?

 

The way i make the videos play is by adding a ?title="..." in the a href tags  in the descriptions.php page and  then on play_video.php use a  "$_GET" video title  php tag in the player file path  to play the video. Videos are stored in a folder.

 

On descriptions.php have hyperlink <a href> wrapped around thumbnails(ABCD..) and wrapped around text description, so user can click thumbnail or description to get to play_video.php

Link to comment
Share on other sites

Thank you for corresponding

Not sure i clearly understand this last reply.

I know what is an "include" but i only want ONE video play page, so i suppose i will

need a code that fetches the right include every time, for descriptions-->doesn't a page that's got too many includes

create slow page load?

 

How about a solution where each description paragraph has some sort of an "id" that is fetched by play page, but how?

Link to comment
Share on other sites

Sure, you could wrap something around each item on your descriptions.php and then scrape the page for the right one every time, but that is not very efficient. You would have to load all of the descriptions and look for the right one, just to display one. 

 

Splitting all of your descriptions up into separate files and including them all on descriptions.php and then including only specific one on play_video.php would be a lot faster and more efficient.

 

What would be even better is if you stored all your information in database.  Select and display all on descriptions.php and select and display one on play_video.php

 

 

 

Link to comment
Share on other sites

So are you saying that retrieving from DB is faster than retrieving an "include"?

 

Also about :

you could wrap something around each item on your descriptions.php and then scrape the page for the right one every time, but that is not very efficient

 

I am doing some reading about javascript DOM to see if i can do it with a "innerHTML  / x.childNodes / onClick "type device, this would directly fetch  the one part i need when moving from page.

Link to comment
Share on other sites

i gues that in your directori is some video files (video1.avi, video2.avi, video3.avi and so on)

add sam files with descriptions (video1.des, video2.des etc.)

video1.des is file with html for description of video1.avi and  thumbnail

in descriptions.php use

<?php
$files = glob('*.avi');
foreach ($files as $file){
    $file =explode('.', $file);
    $f_name = $file[0];
    
    if(file_exists($f_name.'.des')){
        echo "<a href='play_video?title=$f_name'><div class='description'>\n";
        include($f_name.'.des');
        echo "</div></a>\n";
    }
}
?>

Link to comment
Share on other sites

If I understand your situation correctly, a javascript solution like that is not going to work.  You start out on descriptions.php and click a link that takes you to play_video.php.  You are either one one page or the other.  Those are two separate pages that each have their own DOM. 

 

When you click the link from descriptions.php and go to play_video.php, the browser (which is where javascript is executed - that is, client-side) no longer knows anything about descriptions.php except for in more vague terms (for example, it knows that it was the previous page you were on, which is how the back button works). 

 

On play_video.php you could technically use javascript to request the contents of descriptions.php and then try to parse it from there, but it wouldn't be through the DOM, it would be with regex or if you have a framework like jquery, you could possibly retrieve it as if it were xml.  But even this is still way less efficient than having your descriptions in separate files and including them all on descriptions.php and including specific one on play_video.php.

 

Alternatively on descriptions.php you could onclick of link pass the info to play_video.php by grabbing the description with javascript and appending it to the target url, and then using javascript (or php if you do it server-side) to add it.  But this is not efficient either.  For one thing, you are passing a whole bunch of extra info in a request.  You will have to urlencode and decode it to make sure random characters in the description don't break the url.  Then you will have to add more script to validate the description because once you do something like this, this opens a door to all kinds of security concerns that you will need to address, like cross-site scripting, code injection, etc.. 

 

So are you saying that retrieving from DB is faster than retrieving an "include"

 

Well that depends on what you ultimately are doing.  It seems to me that for now, you aren't going to notice a difference in speed either way.

 

And anyways, I'm not sure why you are shying away from the notion of keeping each description in separate files (or in a database as separate entries of a table) in the first place.  It will not have some huge performance decrease that you think it will.  Many people misunderstand the notion of "performance increase/decrease" and consequently blow it way out of proportion.  In reality, we're talking microsecond level of differences here...

Link to comment
Share on other sites

I tried reading up on activating a hyperlink with javascript in order to be able to retieve the video title before the a href was activated, but after a few hours i felt it was too much trouble, i really do not have that much time for this problem right away.

Thank you guys for chatting, it was educative,may be i will pursue it later on.

 

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.