From the homepage I will click on an image which has an id and then be directed to a page which shows more details about that id.
I want to have a facebook like button on the page that would contain information about that specific id but I don't know what to type in the data-href
<div class="fb-like" data-href="http://www.test.com/php/test.php?id=" data-send="true" data-width="150" data-show-faces="false"></div>
specify that is it static or coming from database ?
for database, pass the php variable in the url:
echo "<div class='fb-like' data-href='http://www.test.com/php/test.php?id='".$id."data-send='true' data-width='150' data-show-faces='false'></div>";
Related
I have a simple page. On this page, I have blocks. The blocks get their unique ids when clicked open (example: http://blog.com/#brands). The ids are variable:
<div class="block wide" id="<?php echo $postid ; ?>">
blog category
</div>
Someone clicks the link in the block & goes to the blog. Now the visitor is on the blog category page. But the visitor wants to go back to the homepage:
<span class="return-back">back</span>
But now, it is back to the top of the homepage. I want the visitor to be back at the variable id anchor of the blog:
<div class="block wide" id="<?php echo $postid ; ?>">
How do we make this happen? I am not a PHP developer (just CSS/JS/HTML). I've used Wordpress for this project. Thank you all so much!
The format for linking to a div through url is:
mypage.com/blog#blog_id
where blog_id is the id of the div you'd like to link to.
So, assuming $postid is the id of the div you want to link back to, try this:
back
This is actually impossible to solve without rebuilding everything. The next page doesn't know what $postid is.
Through php i want to redirect the user to specific location :
header('Location:http://localhost/diplomska/#more')
and the url in the browser after redirect is :
http://localhost/diplomska/#more
But it still points to the home page. Even if i manualy write it in the browser, it is still the same. However, if i click the navigation link that go to the page #more , it works.
I have added data-url attribute, but still the same . Code in addition:
<div id = "more" data-role="page" data-url="http://localhost/diplomska/#more"data-title="More about you" >
And the link that work when i click on it is :
<a id="more" href="#more"
data-transation="slidedown"
data-role="button"
data-icon="arrow-d"
data-mini="true"
data-iconpos="top"
>More</a>
You can't have more than one element with a given id on a page. Remove the id from your anchor, it's href attribute references the div you want to jump to.
I asked a similar question over here (http://stackoverflow.com/questions/13856915/contact-form-including-referral-of-previous-page).
"I have a php contact form using POST and I want to automatically include the referring page on the form, that is the website linking to the contact form. This would normally be within my website." I now have HTTP_REFERER working fine on my contact form to show the previous page link.
My next step is to have the same/similar result, but the referring page has a number of tours listed on the same page, so just including the URL isn't enough. I want to know which link/button they clicked to find the contact form.
Here is an example:
On tours.php I have the following code (multiple times on the same page):
<a href="<?php echo($domain); ?>/contact/booknow.php" </a>
I could change that to:
<a href="<?php echo($domain); ?>/contact/booknow.php?tourname" </a>
<a href="<?php echo($domain); ?>/contact/booknow.php?tourname2" </a>
On the contact form I want to store that they came from tours.php and tourname2, etc.
So how can I store that information on the contact form, so I know which button they clicked on (which tour they are interested in)?
Or do I need to add another variable in the link on the tour.php page?
Many thanks,
Andy
booknow.php?tourname1
booknow.php?tourname2
booknow.php?tourname3
When clicked, your next page will have access to $_GET['tourname1'] or $_GET['tourname2'] or $_GET['tourname3'] so you can test if they exists and you'll know on which link your visitor clicked.
I would suggest to change a bit for something like this :
booknow.php?tourname=1
booknow.php?tourname=2
booknow.php?tourname=3
So you can check if "tourname" exist and if so get its value "$_GET['tourname']".
Here you go :
$ref_url = $_SERVER['HTTP_REFERER'];
$ref_link = 0;
if( isset($_GET['tourname']) ) {
$ref_link = $_GET['tourname'];
}
i have one page on that page having multiple images.On each image have their own share and like button.when i click on share button i want to share that perticular image but that is not happening please help me.
here is my code..
<script type="text/javascript">
var str;
function fbs_click(u,val)
{
var i;
var imgobj=document.getElementById(val).getElementsByTagName('img');
for(i=0;i<imgobj.length;i++){
str=imgobj[i].src;
//document.write("<br>");
}
alert(str);
//This is to show fb popup for sharing passed pageurl
window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u),'sharer','toolbar=0,status=0,width=626,height=436');
return false;
}
</script>
<!--This is for setting img for fb like -->
<script type="text/javascript">document.write('<link rel="image_src" type="image/jpeg" href="'+str+'">');</script>
$url="http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
<div class='sharebutton'>
<a href='#' onclick='return fbs_click(\"$url\",\"$src_value\");' class='fb_share_link'>Share on Facebook</a>
</div>
i have paste the code is short just understand you my problem
The problem is, you're only sending the page url. Facebook indexes its like counts based on the url.
Since Facebook has no idea which image on the page the user is intending to share, it grabs your default meta tags for the page and that's what shows up on the user's timeline. Since the urls for each photo are the same, sharing any one photo will result in the counter being incremented for all photos.
One way to make this work would be to create a separate page for each image on your site and pass that in your onclick function. That page has specific metadata for that image the Facebook parser can use. When a user follows that link, have a script on that page to redirect them back to your main page (preferably to an anchor at the right photo). You'll need to have some way to fail gracefully for people who don't have javascript enabled.
Im trying to update a database field without refreshing the page
what im using is:
<a class="youtube" href="#" rel="<?php echo $row['link'];?>" title="<?php echo $row['title']; ?>" >
<div class="overlay_play"></div>
</a>
Then i want to update from this video ( they all have unique id's ofc) the field plays
My table looks like this:
id - int(9)
title - text
link - text
plays - int(99)
So in short
I have a video list of 6 video's on one page and you can play them in a popup window
But what i want is if you click play video that the plays field will be updated
The popup window is done with jquery ( like lightbox ) so i can't refresh the page.
Its easy ,you can do this by using ajax along with php page
if(playbutton pressed) {
//perform the database operation in through calling a ajax page
//using jquery post one of them
$.post('ajax/save.php', function(data) {
$('.result').html(data);
});
}
save.php
//Contains all the database operations to save the field