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
}
?>
Related
Im trying to send the patient ID through a hyperlink, tho while it redirects to the correct page it is not sending the information.
<a href="./patientrecord.php?patient_id="<?php $row["patient_id"]?>><?php echo $row["surname"];?></a>
Please make sure you are going to echo the variable
Echoing a variable:
<?= $echoable_variable_here ?> // Use <?= ?> tags
or
<?php echo $echoable_variable_here ?> // Use echo inside <?php ?> tags
Edit: You have placed echo outside the href attribute tag
Therefore,
Change this:
<a href="./patientrecord.php?patient_id="<?php $row["patient_id"]?>><?php echo $row["surname"];?></a>
to:
<?php echo $row["surname"];?>
or to:
<?php echo $row["surname"];?>
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'];
?>
trying to insert an image into some php. This code pulls from the database thumbnail page to show an item's details. It works fine when it's text "see it in 3d view" but when I try to insert a premade image in that location instead (a button jpg, aka "img src="#"), I'm getting an error. How can I do this correctly? Still learning the ins and outs of php and html, they don't always play the way I expect them to. Thanks for any help.
echo ("<br><img src= \"");
echo ($thumbnail);
echo (" \"><br><br><a href = \"");
echo ($photo);
echo ("\"><b>See it in 360 view</b></a></div>");
echo ("<div id=\"info\"; style=\"width:45%\"><br><br><div class = \"date\">");
echo ($date);
echo ("</div><br>");
echo ("<div class = \"blurbs\">");
echo ($sub);
echo ("<br><br><br>");
echo ($desc);
echo ("<br><br>");
echo ($hist);
echo ("<br><br><br><b>Provenance:</b><br>");
echo ($prov);
echo ("<br><br><b>Construction Label:</b><br>");
echo ($labl);
echo ("<br><br><br><br><b>");
echo ($cNum);
echo ("</b>");
<img src="#"> would never work. src="#" is a shortcut for "current page". e.g. browsers will try to use the current page's URL as the source for the image, which means it'll be trying to load a bunch of HTML as if it was a jpg/gif/png image. Since html isn't any of those, it'll just be a flat-out "this image contains errors" error.
Whatever you're putting in $thumbnail needs to be a proper url, e.g.
<img src="kittens.jpg">
<img src="http://example.com/kittens.jpg">
<img src="data:image/jpeg;base64,<?php echp base64_encode(file_get_contents('kittens.jpg')); ?>">
I would start out with cleaning up your file and remove some of the unneeded overhead (I personally love to have my controllers (Which is generating the output for my view files)
What is the output of this PHP file and what did you expect it to be?
<br><img src="<?= $thumbnail ?>">
<br><br><b>See it in 360 view</b>
</div>
<div id="info" style="width:45%"><br><br><div class = "date">
<?= $date ?>
</div><br>
<div class="blurbs">
<?= $sub ?>
<br><br><br>
<?= $desc ?>
<br><br>
<?= $hist ?>
<br><br><br><b>Provenance:</b><br>
<?= $prov ?>
<br><br><b>Construction Label:</b><br>
<?= $labl ?>
<br><br><br><br><b>
<?= $cNum ?>
</b>
a note to this is that Short Open tag which is enabled by default from PHP 5.4)
You should also look into using div or p tags instead of all the line breaks (it makes it easier for you to make changes to later on)
Hey guys how can I send one variable to 2 web pages connect.inc.php and image.php when a link is clicked but only open another page e.g link.php using $_Get. Its not working for me as am not getting the variable.
Am sending it from index.php as follows
<a href="link.php?connectlink.inc.php?num=<?php echo htmlspecialchars($value, ENT_QUOTES, `'UTF-8'); ?>" ><h3 ><?php echo htmlspecialchars($data[$key], ENT_QUOTES, 'UTF-8'); ?> </h3></a>`
<p >
and this is what am using to retrieve it at connectlink.php and image.php
$numb= $_GET['num'];
Am not getting any errors bt am also not geting the variable to the 2 php files
You should use & when adding more than one GET parameters:
<a href="link.php?connectlink.inc.php&num=<?php echo htmlspecialchars($value, ENT_QUOTES, `'UTF-8'); ?>" ><h3 ><?php echo htmlspecialchars($data[$key], ENT_QUOTES, 'UTF-8'); ?> </h3></a>
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>