I have create a form, after details have been submitted I am trying to open an Iframe for the response. But I keep receiving an error in the line in bold.
This is my code:
// this code is within my php code
if($result){
**echo <li><iframe width="420" height="315" src="datasave.php" frameborder="0"></iframe></li>**
}
else{
echo"ERROR"
}
datasave.php ==> This is the code in this file
<?php
echo Your details have been sent successfully!;
?>
Either:
Leave PHP mode if you want to go into output mode. You can't just put raw HTML where PHP is expected.
if($result){
?>
<li><iframe width="420" height="315" src="datasave.php" frameborder="0"></iframe></li>
<?php
}
or
Put delimiters (" or ' usually) around your PHP strings.
if($result){
echo '<li><iframe width="420" height="315" src="datasave.php" frameborder="0"></iframe></li>';
}
Just replace your this line
**echo <li><iframe width="420" height="315" src="datasave.php" frameborder="0"></iframe></li>**
with this one
echo '<li><iframe width="420" height="315" src="datasave.php" frameborder="0"></iframe></li>';
Related
I want to display the youtube link stored in the database and just call the link but it can't
<div class="divideo">
<iframe width="560" height="315" src="<?php echo $link; ?>" frameborder="0" allowfullscreen></iframe>
</div>
but youtube can't connect
<div class="divideo">
<iframe width="560" height="315" src="<?php echo base_url(); ?>/path/<?php echo $link ?>" frameborder="0" allowfullscreen></iframe>
</div>
You should have to give the proper path of the video link if that link is in your server if you are using an external source then use a proper link in your src tag.
So what I would like to do is there is a variable if the variable = 4 it shows the embedded map, is it possible ? Like use echo or print ?
<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3690.394035580924!2d114.14653071466621!3d22.33874584714393!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x3404007b6cca3859%3A0xf78318a768321055!2sFlow%20Bookshop!5e0!3m2!1sen!2shk!4v1620637580481!5m2!1sen!2shk" width="600" height="450" style="border:0;" allowfullscreen="" loading="lazy"></iframe>
Assuming this HTML is within a .php file, then just use an if statement:
<?php if ($x == 4) { ?>
<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d3690.394035580924!2d114.14653071466621!3d22.33874584714393!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x3404007b6cca3859%3A0xf78318a768321055!2sFlow%20Bookshop!5e0!3m2!1sen!2shk!4v1620637580481!5m2!1sen!2shk" width="600" height="450" style="border:0;" allowfullscreen="" loading="lazy"></iframe>
<?php } ?>
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 need help creating Wordpress function to make shortcode [youtube-id=ID] in post editor output the following html code with ID value included:
<iframe width="420" height="315" src="https://www.youtube.com/embed/ID?rel=0" frameborder="0" allowfullscreen></iframe>
in your functions.php
function YouTubeID($atts, $content = null) {
extract(shortcode_atts(array('id'=>''), $atts));
return '<iframe width="420" height="315" src="https://www.youtube.com/embed/'.$id.'?rel=0" frameborder="0" allowfullscreen></iframe>';
}
add_shortcode('youtube', 'YouTubeID');
wherever you want the video the shortcode will be:
[youtube id="THE_ID"]
Try this
function my_amazing_shortcode_handler($args)
{
$args=shortcode_atts(array('id' => 'some_default_id'), $args);
return '<iframe width="420" height="315" src="https://www.youtube.com/embed/' . $args['id'] . '?rel=0" frameborder="0" allowfullscreen></iframe>';
}
add_shortcode('youtube_iframe', 'my_amazing_shortcode_handler');
Use like [youtube_iframe id='some_id']
For reference: add_shortcode, shortcode_atts
After more than 3 hours searching in google, I found that ppl do the other way around of what I am doing but anyway, here is what I want to do:
I have a variable $location which contains an HTML code (embedded google map code) i.e.
<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0"
marginwidth="0" src="https://www.google.com/maps/ms?........in a larger
map></iframe>
now in a php code, how can i get the map to be displayed?
the following outputs the HTML code as text
<?php echo $loation; ?>
Thanks!
You spelled your variable name wrong $loation; - should be $location;. Assuming you set your variable correctly like
$location = '...';
OR using heredoc syntax:
$location = <<<STR
<iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0"
marginwidth="0" src="https://www.google.com/maps/ms?........in a larger
map></iframe>
STR;
you should be fine.