I'm trying to create a conditional for a theme in a Wordpress,
If the meta exist show this... else show that.
<?php
$scene_trailer = get_post_meta($post->ID, 'scene_trailer', true);
if ( $scene_trailer ) {
echo htmlentities('<div style="width: 645px; height: 364px; overflow: hidden">
<iframe src="http://tvguide.com/<?php $key="scene_number"; echo get_post_meta($post->ID, $key, true); ?>/" width="645" height="430" scrolling="no" frameborder="0" style="position: relative; top: -36px"></iframe></div>');
}
else {
echo '<img src="http://i0.tvguide.com/<?php $key="scene_number"; echo get_post_meta($post->ID, $key, true); ?>/576x324.jpg" width="576" height="324" alt="" />';
}
?>
My code returns this as plain text:
<div style="width: 645px; height: 364px; overflow: hidden"> <iframe src="http://tvguide.com<?php $key="scene_number"; echo get_post_meta($post->ID, $key, true); ?>/" width="645" height="430" scrolling="no" frameborder="0" style="position: relative; top: -36px"></iframe></div>
Can someone please show me what I'm doing wrong?
Thanks!
You have write wrong php syntax Please try below code.
<?php
$scene_trailer = get_post_meta($post->ID, 'scene_trailer', true);
if ($scene_trailer) {
$key = "scene_number";
$scene_number = get_post_meta($post->ID, $key, true);
echo htmlentities('<div style="width: 645px; height: 364px; overflow: hidden">
<iframe src="http://tvguide.com/' . $scene_number . '" width="645" height="430" scrolling="no" frameborder="0" style="position: relative; top: -36px"></iframe></div>');
} else {
echo '<img src="http://i0.tvguide.com/scenes/' . $scene_number . '/576x324.jpg" width="576" height="324" alt="" />';
}
?>
Related
In wordpress I'm using a plugin that create this iframe:
<iframe scrolling="no" allowfullscreen="" src="http://...k.jpg&is_stereo=false" width="100%" height="1200px"></iframe>
This is the array of the php page:
$a = shortcode_atts( array(
'img' => '',
'video' => '',
'pimg' => '',
'stereo' => 'false',
'width' => '100%',
'height' => '1200px',
), $atts );
and this the php code:
<iframe width="<?php echo $a['width']; ?>" height="<?php echo $a['height']; ?>" scrolling="no" allowfullscreen src="<?php echo $iframe_url; ?>"></iframe>
The width is perfect and responsive.
I need to have a full height iframe. How?
You can try and see if this works:
<div style="height: 100%; width: 100%;">
<iframe width="<?php echo $a['width']; ?>" height="<?php echo $a['height']; ?>" scrolling="no" style="height:100%;width:100%" allowfullscreen="1" src="<?php echo $iframe_url; ?>"></iframe>
</div>
OUTPUT SHOULD BE
<div style="height: 100%; width: 100%;">
<iframe scrolling="no" allowfullscreen="1" src="http://...k.jpg&is_stereo=false" style="height:100%;width:100%" width="100%" height="1200px"></iframe></div>
my code is:
$retval = preg_match('/<img.+src=[\'"](?P<src>.+)[\'"].*>/i', $content, $image);
$imgreal = str_replace(""", "\"", $image['src']);
if ($retval=="0") $imgthumb = ""; else $imgthumb = "<img align='left' src='".$imgreal."' width=100 />";
I need to extract an img from a string, but this gave me all time:
"http://www.racingzone.hu/pictures/news/mid/simroc-3---nyolc-uj-auto_2012-09-21-1348222495.jpg" alt="" width="490" height="214
How can I change those "es to normal chars "?
I tried htmlspecialchars_decode but that not worked to.
edit: the string coming from az sql table.
original string from mysql:
<p><img style="float: left; margin: 3px;" src="http://www.racingzone.hu/pictures/news/mid/simroc-3---nyolc-uj-auto_2012-09-21-1348222495.jpg" alt="" width="490" height="214" /></p>
<p>todik púőúőóüsztotodik púőúőóüsztotodik
string created by TinyMCE
coding in the table: latin2_hungarian_ci
Why does everybody always want to do these kind of things with a regex?
Simply:
$data='<p><img style="float: left; margin: 3px;" src="http://www.racingzone.hu/pictures/news/mid/simroc-3---nyolc-uj-auto_2012-09-21-1348222495.jpg" alt="" width="490" height="214" /></p>
<p>todik púőúőóüsztotodik púőúőóüsztotodik';
$a=explode('src="',$data);
if(count($a)<2)
{
echo 'no image';
die;
}
$p=strpos($a[1],'"',0);
if($p===false){
echo 'no quote found';
die;
}
$url=substr($a[1],0,$p);
echo $url;
Output:
http://www.racingzone.hu/pictures/news/mid/simroc-3---nyolc-uj-auto_2012-09-21-1348222495.jpg
i want if there is no input such as http://bloxhotel.nl/video?watch=YxIiPLVR6NA
That a box will not pop up
<?php
ob_start();
include 'includes/inc.bootstrap.php';
$page = Array('title' => ((isset($user)) ? $user->username : ''), 'onload' => ((isset($_GET['utm_source']) && $_GET['utm_source'] == 'welcome') ? 'Pixel.View.OpenUrlOverlay(\'/pixlett/Video.php\');' : ''), 'tab' => Array('me', 'home'), 'access' => Array(true, false));
include 'content/header.php';
include 'content/menu.php';
?>
<center>
<div class="c_box" style="overflow: hidden; width: 58%; height: 10%;">
<div class="heading blue">Ga naar Video</div>
<tr style="padding: 4px;">
<html>
<body>
<form action="welcome_get.php" method="get">
Youtube Link: <input type="text" name="link"><br>
<input type="submit">
</form>
</body>
</html>
</div>
<center>
<div class="c_box" style="overflow: hidden; width: 58%; height: 10%;">
<div class="heading blue">Video</div>
<?php
$watch = $_GET['watch'];
$embed = '<embed src="http://bloxhotel.nl/Player7.swf" flashVars="video_id='.$watch.'" style="width: 100%; height: 57%;" allowScriptAccess="always" autoplay="false" allowFullscreen="true" type="application/x-shockwave-flash" wmode="transparent" id="player_demo"></embed></object>';
echo $embed;
?>
</div>
</center>
This
<?php
$watch = $_GET['watch'];
$embed = '<embed src="http://bloxhotel.nl/Player7.swf" flashVars="video_id='.$watch.'" style="width: 100%; height: 57%;" allowScriptAccess="always" autoplay="false" allowFullscreen="true" type="application/x-shockwave-flash" wmode="transparent" id="player_demo"></embed></object>';
echo $embed;
?>
Need to not show up
So if there is no input in video?watch= the box needs to keep hidden
Can someone help
Do you expect something like this?
<?php
$watch = trim($_GET['watch']);
if($watch!=""){
?>
<div class="c_box" style="overflow: hidden; width: 58%; height: 10%;">
<div class="heading blue">Video</div>
<?php
$embed = '<embed src="http://bloxhotel.nl/Player7.swf" flashVars="video_id='.$watch.'" style="width: 100%; height: 57%;" allowScriptAccess="always" autoplay="false" allowFullscreen="true" type="application/x-shockwave-flash" wmode="transparent" id="player_demo"></embed></object>';
echo $embed;
?>
</div>
<?php } ?>
simply check
if(!empty($_GET['watch']) {echo $some_other_text; //or echo '';} else {echo $embed}
In that way, it will check weather the watch is empty or not.
you can also check if the ?watch is added or not as follow:
if(!isset($_GET['watch'])||!empty($_GET['watch'])) {//do not echo your box}
else {//echo your box}
in the below code i am searching a data before searching my url will be in coursemaster_site and when i search it will be in coursemaster_site/index1 and when i close the search results the url will be in coursemaster_site /coursemaster_site but i want url to be in coursemaster_site after closing the search results.
controller:coursemaster_site
function index1()
{
$data = array();
$keyword = $this->input->post('keyword');
if($keyword!=""){
$data['results'] = $this->coursemaster_model->search($keyword);
}
$this->load->view('coursemaster_view', $data);
}
view:coursemaster_view
<form action="<?php echo site_url('coursemaster_site/index1');?>" method = "post">
<br/><center>SEARCH:<input type="text" name = "keyword" required/>
<input type="submit" name="submit" id="opn" value = "Search" onClick="hide1('hiddendiv')" class="btn-success btn" /></center>
</form>
<?php
if (isset($_POST['submit'])) { // Here
// Do the search here
if($results){
?> <div id='hideme'>
CLOSE<a href='coursemaster_site' class='close_notification' title='Click to Close'>
<img src="<?php echo base_url('img/close.png'); ?>" width="15" height="15" alt="Close" onClick="hide('hideme')"/>
</a><div style="background:#FFFFFF; width:1000px; height: 540px; position: absolute; left: 20%; top: 35%; margin-left: -100px; margin-top: -120px" id="modal" >
<table class="display2 table table-bordered table-striped" id='results'>
<tr>
<th>course_code</th>
<th>course name</th>
</tr>
<tr><?php
foreach ($results as $row) {
?>
<td><?php echo $row->course_code;?></td>
<td><?php echo $row->course_name;?></td>
</tr>
<?php
}
}else{
echo"<div id='hideme'>
CLOSE<a href='coursemaster_site' class='close_notification' title='Click to Close'>";
echo "<div id='modal' style='background:#FFFFFF; width:1000px; height: 525px; position: absolute; left: 20%; top: 35%; margin-left: -100px; margin-top: -110px'>";
}
echo"no results";
echo'</div>';
echo '</div>'; }
// If closing
?>
</table>
</div></div>
<script>
$('a.modal').bind('click', function(event) {
event.preventDefault();
$('#modal').fadeIn(10);
});
function hide(obj) {
var el = document.getElementById(obj);
el.style.display = 'none';
}
function hide1(obj) {
var el = document.getElementById(obj);
el.style.display = 'none';
}
</script>
Change to:
<div id='hideme'>CLOSE
<a href='/coursemaster_site' class='close_notification' title='Click to Close'>
...
on both places. The leading slash makes the href start from root.
Do the following changes and check if it works or not:
<div id='hideme'>
CLOSE<a href='javascript:void(0);' class='close_notification' title='Click to Close'>";
Can anyone help me converting Html to PHP
I want to add a paypal button to my woocommerce website but I am running into a few errors.
here is the code I have in html format
<a class="paypal_checkout_button" href="websitelinkhere"><img src="https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif" width="145" height="42" style="width: 145px; height: 42px; padding-top: 30px; padding-left:20px; " border="0" align="top" alt="Check out with PayPal"></a>
Basically im using the theme - theretailer.getbowtied.com/demo the shopping cart dropdown at the top of the main page im trying to add the button into that but cant get it to display
Any help would be amazing
Edit*
this is the page im trying to add the code to
<div class="gbtr_minicart_wrapper">
<div class="gbtr_minicart">
<?php echo '<a class="paypal_checkout_button" href="websitelinkhere"><img src="https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif" width="145" height="42" style="width: 145px; height: 42px; padding-top: 30px; padding-left:20px; " border="0" align="top" alt="Check out with PayPal"></a>';?>
<?php
echo '<ul class="cart_list">';
if (sizeof($woocommerce->cart->cart_contents)>0) : foreach ($woocommerce->cart->cart_contents as $cart_item_key => $cart_item) :
$_product = $cart_item['data'];
if ($_product->exists() && $cart_item['quantity']>0) :
echo '<li class="cart_list_product">';
echo '<a class="cart_list_product_img" href="'.get_permalink($cart_item['product_id']).'">' . $_product->get_image().'</a>';
echo '<div class="cart_list_product_title">';
$gbtr_product_title = $_product->get_title();
//$gbtr_short_product_title = (strlen($gbtr_product_title) > 28) ? substr($gbtr_product_title, 0, 25) . '...' : $gbtr_product_title;
echo '' . apply_filters('woocommerce_cart_widget_product_title', $gbtr_product_title, $_product) . '';
echo '<div class="cart_list_product_quantity">'.__('Quantity:', 'theretailer').' '.$cart_item['quantity'].'</div>';
echo '</div>';
echo apply_filters( 'woocommerce_cart_item_remove_link', sprintf('×', esc_url( $woocommerce->cart->get_remove_url( $cart_item_key ) ), __('Remove this item', 'woocommerce') ), $cart_item_key );
echo '<div class="cart_list_product_price">'.woocommerce_price($_product->get_price()).'</div>';
echo '<div class="clr"></div>';
echo '</li>';
endif;
endforeach;
?>
<div class="minicart_total_checkout">
<?php _e('Cart subtotal', 'theretailer'); ?><span>
<?php echo $woocommerce->cart->get_cart_total(); ?></span>
</div>
<?php _e('View Shopping Bag', 'theretailer'); ?>
<?php _e('Proceed to Checkout', 'theretailer'); ?>
<?php
else: echo '<li class="empty">'.__('No products in the cart.','woocommerce').'</li>'; endif;
echo '</ul>';
?>
</div>
</div>
</div>
<span><?php echo $woocommerce->cart->cart_contents_count; ?></span>
</div>
Im looking for it to go under the buttons
Im looking for it to go into the gbtr_minicart section under the buttons
here you go
//some php code
?>
<a class="paypal_checkout_button" href="websitelinkhere"><img src="https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif" width="145" height="42" style="width: 145px; height: 42px; padding-top: 30px; padding-left:20px; " border="0" align="top" alt="Check out with PayPal"></a>
<?php
//php code again
<?php
echo '<a class="paypal_checkout_button" href="websitelinkhere"><img src="https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif" width="145" height="42" style="width: 145px; height: 42px; padding-top: 30px; padding-left:20px; " border="0" align="top" alt="Check out with PayPal"></a>';
?>