Html slider text with php data - php

I try to get a news text slider and i try to do it with marquee html code,
but its seams i do some thing wrong, i have try a few times to get it work and faild.
This is the current code
$html= '<marquee behavior="slide" direction="left">'.echo $row['title'].'</marquee>';

HTML marquee tag, already deprecated. You may use instead it Text-Scrolling-Plugin jQuery plugin
For more information Enter here
Additionally, enter your $text in other side and check it. Perhaps exits any error..
echo $text;

Related

How to display a text file hosted on another server inside a Blogger post

I need to read a text file on a server and display its content in a blog post on Blogger. The text file is a result of a simple download counter and contains a number. The problem is the Blogger does not support PHP codes in a post. My current solution is to use OBJECT tag to call PHP script that displays the text file content with ECHO. It works. But the result is displayed inside a small frame and I can't apply CSS style to it or align it properly with the existing text. Is there another way? I understand it can be done with AJAX call but my scripting knowledge is basic and I wouldn't know where to begin. Help would be appreciated.
To display the result in the blog I used this code:
<p>File test.zip downloaded
<object type="text/plain"
data="http://example.com/statistics.php?dname=test"
width="30" height="30"></object> times</p>
EDIT: I have tried to follow #Toni suggestion but it only leads to more questions. Looks like Ajax call is way beyond my current level of knowledge. Sorry and thank you again.
Here is what I'm currently trying. I have moved the text that goes with the counter inside PHP file so the script now returns a string like "file has been downloaded 8 times" instead of just number "8". Also instead of OBJECT tag I'm using IFRAME.
<iframe src="http://example.com/mystats.php?dname=test"
frameborder="0" border="0" cells pacing="0" height="30"></iframe>
The iframe seems to be easier to style. If I can't figure out how to find which CSS is applied to a blog post and how to apply it to iframe, I can at the minimum mimic the style by using similar font.
You can use javascript with your blogger web-site.
Using javascript on your web-page, you can invoke a GET request to your PHP code and get the data you want, to display it on your web-page.
Below, there are links, to help you with this task:
How to invoke GET request in vanilla JavaScript
Invoking GET with jQuery
Use JavaScript to alter text dynamically
I made it work with JavaScript! Here is how. Server side PHP script reads and echoes a text file inside document.write().
<?php
$varcontent = #file_get_contents('yourtextfile.txt');
echo 'document.write("'.$varcontent.'")';
?>
The resulting string looks like this:
document.write("your text file content here")
Inside the Blogger post add the JavaScript code with the PHP script file as a source:
<script type="text/javascript"
src="http://example.com/yourfile.php">
</script>
Done! The content of your text file is displayed and styled with your current CSS.

file_get_contents returns the text in an html file

I am facing a problem with file_get_contents recently...
When I use it to fetch webpages from the web, it works fine, but when I use it to open a local page it outputs only the text in the page.
i.e. when I use it as
file_get_contents("http://www.google.com");
and echo it I get the google page and its entire structure but when I use
file_get_contents("localfile.html");
and echo it it just outputs the text in the page without the tags.
It is because, HTML tags are parsed by the browser. Use htmlentities this way:
htmlentities(file_get_contents("localfile.html"));
But one thing, when you see the source of the file, it shows you what you need. Also, alternatively you can output this inside a textarea.
<textarea><?php echo htmlentities(file_get_contents("localfile.html")); ?></textarea>

Get all HTML comments on website with html simple dom

I've tried to grab all the comments from a website (The text between <!-- and -->), but without luck.
Here is my current code:
include('simple_html_dom.php');
$html = file_get_html('THE URL');
foreach($html->find('comment') as $element)
echo $element->plaintext;
Anyone have any ideas how to grab the comments, at the moment it's only giving me a blank page
I know regex is not supposed to parse HTML, but <!--(.*?)--> you can use a similar regex to find and fetch the comments...

How to echo a div class?

Not sure how to do this... I'm a bit of a php noob. I'm trying to echo the div class '.header1'
In my css I've given .header1 a background image and I want that to appear, but I'm not having any luck so my code must be wrong. Here it is:
echo '<div class="header1">';
.header1 {
background: url(_images/header1.png);
What am I doing wrong? I've tried it with and without the closing div but neither have worked.
The div tag needs both an ending tag and content.
If there is no content, you need to define it's height and width manually.
A. You echo is working .. you are probably not seeing anything because its an HTML tag try
<?php
echo '<div class="header1">Hello</div>';
?>
B. You should try and make sure you set PHP open tag <?php and close tag ?> as demostrated above
Whenever I echo html in php I like to use the heredoc syntax
$div = <<<DIV
<div class="header1"></div>
DIV;
Just looks so much better, to me, especially when your strings get more complex, i.e. quotes and stuff.

tinyMCE media embed, with media plugin in PHP + MySql

i'm using tinyMCE and i can't find the answer for this in their forums.
I'm using the "media" plugin to embed flash. the html result in html preview is normal:
<p><iframe src="http://www.youtube.com/embed/lWRi7gDYjVY" frameborder="0" width="425" height="350"></iframe></p>
the result saved to the database is quite different though, using mysql_real_escape_string it saves:
<p><img data-mce-json="{'type':'iframe','video':{'sources':[]},'params':{'src':'http://www.youtube.com/embed/lWRi7gDYjVY','frameborder':'0'},'width':'425','height':'350'}" class="mceItemMedia mceItemIframe" src="http://localhost/assets/scripts/tiny_mce/themes/advanced/img/trans.gif" data-mce-src="assets/scripts/tiny_mce/themes/advanced/img/trans.gif" width="425" height="350"></p>
and that is what is rendered on my page's html, showing only a white space the size of the iframe...
I'm really stuck and i don't know what to do.
Thanks
/Update/
well, i found out the source of the problem: i am saving my contents through AJAX; i havenĀ“t found a way to get the HTML content out of the editor with javascript so i was hacking it with a jQuery selector:
$('div').find('iframe').contents().find('body').html()
so that way i get the "wrong html" and it only happened with youtube videos so far.
My question is: how can i obtain the editor's HTML so i can post it through AJAX?
Thank you once again.
To obtain the editor's HTML use the following
// this is "content" by default else it is the id of your
// html element you get the editor for (usually a textarea)
var editor_id = 'put_your_editor_id_here';
editor = tinymce.get(editor_id);
var content = editor.getContent();
You may have a closer look at the tinymce API.
This is because the media plugin strips the tags that are considered invalid.
Can you try to change the option Valid_elements in Init and assign to [].
Try it.
good luck

Categories