Echo value into iframe url that is already in an iframe - php

Is there anyway to echo values into an iframe that is already inside an iframe?
I need to echo from the parent url 2 stages down into the 2nd iframe. The values in the parent are held as a php session.

Try, like
<?php
$id=1;
?>
<iframe src="page.php?id='<?php echo $id; ?>'" style=""></iframe>
In page.php
<?php
$id= $_GET['id'];
?>
<iframe src="pages.php?id='<?php echo $id; ?>'" style=""></iframe>

Related

PHP for Site Title

I am trying to make a dynamic title using PHP on my website. My index.php open various client pages client.php. On these client pages on want the clients name to be shown as the page title.
I open the client page with the following PHP link.
<a class="iframe" href="client.php?id=<?php echo $rows['id']; ?>&Client Name=<?php echo $rows['client_name'] ?>">
And here is how I try to carry over the client name as title on client.php, but it just comes as a blank title...
<?php $client_name_title = $_GET['Client Name'];?>
<title><?php echo $client_name_title ?></title>
What am I doing wrong???
You need to pass the variable through the URL without spaces, like so:
<a class="iframe" href="client.php?id=<?php echo $rows['id']; ?>&client_name=<?php echo $rows['client_name'] ?>">
<?php
if(isset($_GET['client_name'])){
$client_name_title = $_GET['client_name'];
} else {
//client not set, revert to default behavior
}
?>

How do i get id from table rows and pass to other page

I am trying to develop an application form app. .
I want to be able to click on an application id and be able to generate the application form in details. So am using Sessions and it only works for the last id in the database.
Basically passing an application ID into a session then calling it as a parameter for the next page. If this method cant work, could there be another? Hope am clear enough.
Here is my code.
<td>
<a href="applicants_details.php"> <?php echo $Applicant->getApplicationID(); ?>
<?php php $_SESSION["SELECTEDID"] = $Applicant->GetApplicationID(); ?>
</td>
Use $_GET,
applications.php
<a href="applicants_details.php?applicant_id=<?php echo $Applicant->GetApplicationID(); ?>"><?php echo $Applicant->GetApplicationID(); ?><\a>
applicant_details.php
<?php
echo $_GET['applicant_id'];
?>
Change your code on the table to:
<td>
<a href="applicants_details.php?id=<?php echo $Applicant->getApplicationID(); ?>">
<?php echo $Applicant->getApplicationID(); ?>
</a>
</td>
Then on the next page you can get the ID with:
<?php
$id = $_GET['id'];
?>

how to diplay page id for review php in div?

I tried several options but they are not working, I have 2 pages, page.php and rating.php, on page.php, I have button with this link
< a href=”rating.php/go.php?id=$rows[$id]”>button</a>
, but on page rating.php I have a div with code.
<div id="review" ><?php echo $rows['id'];?></div>
I want that the $rows[$id]from the link rating.php/go.php?id=$rows[$id] could be displayed on div like this . How can I do that to see this $rows[$id] on div?
On page.php you are using < a href="rating.php?id=$rows[$id]">button</a>
If you want $rows[$id] in your rating.php use $_GET
<div id="review" ><?php echo $_GET['id'];?></div>
Read this tutorials too http://www.tutorialspoint.com/php/php_get_post.htm
you get a param from an url with that code snippet:
<div id="review"><?php echo $_GET['id']; ?></div>
the $row[$id] must be a value, it can't be an object
works as :
<div id="review"><?php echo $_GET['id']; ?></div>
Read this:
http://www.formget.com/php-post-get/

PHP View Counter

I am trying to make a website and it's almost completed but I want to add a view counter so when someone visit the page it count the view and save it into the database.
My script is working fine but the problem is that it continue view count even visitor is viewing anyother page
My pages url show like this
pictures.php?ID=13
I have added this PHP code in *count.php*
<?php
session_start();
if (isset($_SESSION['views'])){
$_SESSION['views']++;
} else {
$_SESSION['views'] =0;
}
//echo $_SESSION['views'];
?>
Page *views.php*
<?php
session_start();
if (isset($_SESSION['$post_id'])){
$_SESSION['$post_id']++;
} else {
$_SESSION['$post_id'] =0;
}
//echo $_SESSION['views'];
?>
<?php
echo "<hr><div align=\"center\">";
echo $_SESSION['$post_id'];
?>
<?php
$save = $_SESSION['$post_id'];
$con=mysqli_connect("localhost","root","123","user");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
mysqli_query($con,"UPDATE save_data SET Views='$save' WHERE ID='$page_id'");
mysqli_close($con);
?>
And added this line in Pictures.php where I want to show and count visits
<?php include("views.php"); ?>
Problem:
When someone visits page pictures.php?ID=8 it will show him page view 1 and save this view in database where ID=8, when he visit page pictures.php?ID=12 it will show him view 2 and save this 2 in database where ID=12. My point is that it is continuously counting instead of each page view.
Thanks in advance
Here is Pictures.php
<?php
include("connection.php");
if(isset($_GET['ID'])){
$page_id = $_GET['ID'];
$select_query = "select * from save_data where ID='$page_id'";
$run_query = mysql_query($select_query);
while($row=mysql_fetch_array($run_query)){
$post_id = $row['ID'];
$post_title = $row['Title'];
$post_image = $row['Name'];
?>
<h3>
<a href="pictures.php?ID=<?php echo $post_id; ?>">
<?php echo $post_title; ?>
</a>
</h3><center>
<form id="search-form" action="javascript:void(0);">
<input type="text" id="dimen" name="dimension" />
<input type="submit" value="Resize" Onclick ="splitString()"/></form>
<div id="sizet">
Type size like 200*300 in box
</div></center>
<div id="img"><img id="myImage" src="uploads/<?php echo $post_image; ?>" /></div>
<?php } }?>
<center>
<div id="postdetails">
<?php include("posted_by.php"); ?></center>
</div>
<?php include("views.php"); ?>
<html>
<link href="css/Pictures.css" rel="stylesheet" type="text/css">
<body>
<head>
<script type="text/javascript">
function splitString()
{
var myDimen=document.getElementById("dimen").value;
var splitDimen = myDimen.split("*");
document.getElementById("myImage").width=splitDimen[0];
document.getElementById("myImage").height=splitDimen[1];
}
</script>
</head>
</body>
Variables inside of single quotes are not evaluated, so regardless of whether $post_id is 8 or 12, $_SESSION['$post_id'] is setting the key named literally $post_id, rather than the key named 12 or 8. Variables are evaluated inside double quotes, so $_SESSION["$post_id"] would work, but the simplest and best way is to use $_SESSION[$post_id] instead.
Additionally, using $_SESSION here is probably not what you want to do. $_SESSION will be different for every user who visits the site, so when a new visitor comes to the site, it will start over with a count of 1. What you probably want to do is load the views value from the database, add one to it, and then save it back to the database. $_SESSION is for keeping data that is specific to a certain user.
Try to use structure like this
$_SESSION['view'][{resource_name}_{resource_id}]
E.g. for picture with id 8 it will be
$_SESSION['views']['picutures_8']++

Multiple JQuery hovercards on one page

I am using the jQuery Hovercard plugin (here) and trying to impliment it with user images pulled from Facebook with their php sdk, here is the code I am using to display the Hovercard:
<?php
$friends = $this->facebook->api('/me/friends');
foreach ($friends["data"] as $value) { ?>
<label id="demo-facebook" data-hovercard="<?php echo $value['id'] ?>">
<img src="https://graph.facebook.com/<?php echo $value["id"] ?>/picture" alt="<?php echo $value["name"] ?>" />
</label>
<?php }
?>
The problem I am having is that the Hovercard will only show for the first users image displayed, after that no Hovercard will show when the image is moused over ?
You should change the CSS selector "demo-facebook" from an id to a class. I haven't used HoverCard before, but that seems like it would be the problem.
An ID specifies one specific element of a page, whereas a class can be re-used on multiple elements.
Also, I think it would be easier to just echo the HTML instead of having a <?php echo $value; ?> everytime you have to insert a PHP value. You could just do echo "<img src='$value'>"; instead of <img src="<?php echo $value; ?>" />. Just seems like it would be easier that way.

Categories