I'm creating a dynamic site with php/mysql. There are few article. So i want to show a facebook like button for every article. How do i do this.
article show with php:
echo "<h2><a href='readmore.php?post_id= ". $id ."'>$sub</a></h2>";
Anyone can help me.
Add following code for each your article, and like button will show on each article:
<iframe src="http://www.facebook.com/plugins/like.php?href=<?php echo "http://www.yousite.com/$yourArticleUrlHere"; ?>&layout=standard&show_faces=false&width=450&action=like&colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:60px;"></iframe>
Hope it helps
echo '<iframe src="http://www.facebook.com/widgets/like.php?href=<?= "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI']; ?>" scrolling="no" frameborder="0" style="border:none; width: 450px; height: 80px;"></iframe>';
Don't forget to include Facebook JavaScript SDK in the beginning, after opening body tag: http://developers.facebook.com/docs/reference/plugins/like/
I hope this code will help:
<?php
// Facebook Like button HTML 5 syntax
echo '<div class="fb-like" data-href="http://www.yourwebsite.com/readmore.php?post_id='.$id.'" data-send="true" data-width="450" data-show-faces="true"></div>';
// Facebook Like button XFBML syntax
echo '<fb:like href="http://www.yourwebsite.com/readmore.php?post_id='.$id.'" send="true" width="450" show_faces="true"></fb:like>';
?>
Related
I want to display youtube video on a page, the following is my code in order to fetch youtube video URL from the database stored in mysql and then display it by iterating using while loop. However, the iframe does not display any video inside it.
<?php
if ($get_result != false) {
while ($row = mysqli_fetch_array($get_result, MYSQLI_ASSOC)) {
?>
<iframe width="560" height="315" src="<?php echo $row["url"]; ?>" frameborder="0" allowfullscreen></iframe>
<?php
}
}
?>
I have also tried using video tag inside while loop but it does not display the Youtube video inside the video player.
Please help me to solve this issue.
You can use Youtube with embed, like this:
<iframe width="560" height="315" src="https://www.youtube.com/embed/<?php echo $row["url"]; ?>?autoplay=1&autohide=1&controls=1&showinfo=0&modestbranding=1&rel=0"></iframe>
The problem is with your URL value.Replace "watch?v=" in video url with "v/" and try again.For example I tried with
<iframe width="560" height="315"
src="https://www.youtube.com//v/txSGdNONUJE" frameborder="0" allowfullscreen></iframe>
The above code will work fine.
I am using iFrame to display video on www.ridesharebuddy.com. I am using autoplay feature in this.
I am doing it this way.
<iframe src="//player.vimeo.com/video/82633004?title=0&byline=0&portrait=0&autoplay=1" width="500" height="320" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
But sometimes it starts even before the whole page is loaded. Can i give some delay in this to load video after 5-10 seconds?
You can append the video link after the page is loaded via jQuery.
<iframe id="vimeo_frame" src="#" width="500" height="320" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
<script>
jQuery(window).load(function()
{
var vimeo_frame = jQuery('#vimeo_frame'),
vimeo_src = 'player.vimeo.com/video/82633004?title=0&byline=0&portrait=0&autoplay=1';
setTimeout(function()
{
vimeo_frame.attr('src', vimeo_src);
}, 2000);
}
</script>
Don't forget to include jQuery ;-)
This is generated Twitter button, I added text inside.
> <iframe allowtransparency="true" frameborder="0" scrolling="no"
> src="http://platform.twitter.com/widgets/tweet_button.1357735024.html#_=1357817606773&count=horizontal&id=twitter-widget-0&lang=en&original_referer=&size=m&text=<?php
> echo $art["title"].'
> http://web.com/article.php?art_id='.$art["id"];?>&url=<?php
> echo
> 'http://web.com/article.php?art_id='.$art[id];?>&via=MyWeb"
> class="twitter-share-button twitter-count-horizontal" style="width:
> 107px; height: 20px;" title="Twitter Tweet Button"
> data-twttr-rendered="true"></iframe>
The problem is, that I cannot add a link into the tweet. When I add it there, there is not displayed even the simple text.
Has anyone similar issue or any help, how to fix it?
Thank you
I would reorganize your code a bit just to make the building of the iframe src easier to follow (there may be a mistake there). You should also make sure that the $art['title'] is urlencoded.
<?php
$iframe_src = 'http://platform.twitter.com/widgets/tweet_button.1357735024.html#_=1357817606773&count=horizontal&id=twitter-widget-0&lang=en&original_referer=&size=m&text=';
$iframe_src .= urlencode($art['title']);
$iframe_src .= 'http://web.com/article.php?art_id='.$art['id'];
$iframe_src .= '&url=http://web.com/article.php?art_id='.$art['id'].'&via=MyWeb';
?>
<iframe allowtransparency="true" frameborder="0" scrolling="no" src="<?php echo $iframe_src; ?>"
class="twitter-share-button twitter-count-horizontal"
style="width:107px; height: 20px;" title="Twitter Tweet Button"
data-twttr-rendered="true"></iframe>
I have a plugin where is displayed some news with a like facebook button.
I would change the width of this like in this site:
(see the right sidebar)
http://www.fanpage.it/moody-s-boccia-anche-la-germania-e-la-prima-volta-per-la-merkel/
This is my site:
http://www.clouderize.it/michele/
For my button I use this url but whatever width value I set, the button dimension not change!
How can I do ?
<iframe
src="http://www.facebook.com/widgets/like.php?href=<? the_permalink(); ?>&layout=button_count&width=450&action=like&colorscheme=light&font&show_faces=false&height=64"
scrolling="no" frameborder="0"
style="border:none;">
</iframe>
try this
#fb-bar iframe{min-height:80px !important;}
<div id="fb-bar">
<fb:like href="link"></fb:like>
</div>
Or
<div id="fb-bar">
<iframe
src="http://www.facebook.com/widgets/like.php?href=<? the_permalink(); ?>&layout=button_count&width=450&action=like&colorscheme=light&font&show_faces=false&height=64"
scrolling="no" frameborder="0"
style="border:none;">
</iframe>
</div>
<iframe src="http://www.facebook.com/plugins/like.php?href=<?php echo 'http://domainame.com/'.$_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'];?>&layout=button_count&show_faces=false&width=120&action=recommend&font=verdana&colorscheme=light&height=21"
scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:120px; height:21px;" allowTransparency="true"></iframe>
But if i'm on http://domainame.com/?bla it prints http://domainame.com//index.php?bla
if i could just send this.href but i don't know how to insert js in-line here,
help?
With your help we got working:
<iframe src="http://www.facebook.com/plugins/like.php?href=<?php echo str_replace("index.php","",'http://'.$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME']); ?>&layout=button_count&show_faces=true&width=150&action=recommend&font&colorscheme=light&height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:120px; height:21px;" allowTransparency="true"></iframe>
can get better?
Try using the following as a value for href:
<?php echo rawurlencode('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); ?>
Try this: <?php echo rawurlencode('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); ?>
(BTW, you should never use $_SERVER['PHP_SELF'] for anything of this sort, due to injection vulnerabilities. Read this for details.)
I image that the page is named index.php and your server sets index.php as the default page, which would mean http://domainame.com//index.php?bla is interchangeable as a page reference to http://domainame.com/?bla.