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}
Related
I have to make a "homepage" type .php page, which contains objects depending on the number of files in a certain folder. The following code is example how the objects should look like, I have arranged them in a table for easier allignment.
.index_poster {
display: inline-block;
margin: auto;
width: 16em;
height: 9em;
-moz-box-shadow: 0 0 2em rgb(180,180,180);
-webkit-box-shadow: 0 0 2em rgb(180,180,180);
box-shadow: 0px 0px 2em rgb(180,180,180);
}
<table style="width:100%">
<tr align="center"><td align="center">
<div>
<script type="text/javascript">
function actualNextSibling(el) { // needed to smooth out default firefox/IE behavior
do { el = el.nextSibling } while (el && el.nodeType !== 1);
return el;
}
</script>
<div onclick="actualNextSibling(this).style.display='block'; this.style.display='none'">
<img class="index_poster" src="posters/BatmanJoker1.jpg" style="cursor: pointer" />
</div>
<div style="display: none">
<video class="index_poster" controls>
<source src="videos/BatmanJoker1.mp4" type="video/mp4">
<source src="" type="video/ogg">
<source src="" type="video/webm">
Your browser does not support the video tag or the file format of this video.
</video>
</div>
</div>
<div>
<form action="https://www.google.com">
<input type="submit" class="button" value="EDIT SUBTITLES">
</form>
</div>
<br><br>
</td>
<td align="center">
<div>
<script type="text/javascript">
function actualNextSibling(el) { // needed to smooth out default firefox/IE behavior
do { el = el.nextSibling } while (el && el.nodeType !== 1);
return el;
}
</script>
<div onclick="actualNextSibling(this).style.display='block'; this.style.display='none'">
<img class="index_poster" src="posters/BatmanJoker2.jpg" style="cursor: pointer" />
</div>
<div style="display: none">
<video class="index_poster" controls>
<source src="videos/BatmanJoker2.mp4" type="video/mp4">
<source src="" type="video/ogg">
<source src="" type="video/webm">
Your browser does not support the video tag or the file format of this video.
</video>
</div>
</div>
<div>
<form action="https://www.google.com">
<input type="submit" class="button" value="EDIT SUBTITLES">
</form>
</div>
<br><br>
</td></tr><table>
My question is how do I create as much objects as the files in /videos/ and /posters/ folders.
I have read some information on how to count files in a .php FileSystem, but I don't seem to find a solution or a similar question.
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="" />';
}
?>
I have view file on my app there is code array I want to get first object of that array without going in loop.
<?php
$result = array_chunk($products->result_array(), 3);
foreach($result as $products){ ?>
<table style="width:100% style="page-break-after:always;" >
<tr>
<?php
foreach($products as $productArray){
$product = (object) $productArray;
echo '<td>';
?>
<div style="width: 100%; height: 210px; border: 1px solid #dddddd; margin: auto 5px 5px 0; padding: 5px;">
<div class="box-header">
<p class="box-title"><FONT SIZE=12><?php echo $product->product_name; ?></FONT></p>
</div>
<div style="height: 100px; text-align: center;">
<?php echo '<img src="'.'uploads/'. $product->photo.'" class="img-responsive" style="height:100px !important; width: 150px !important" />'; ?>
</div>
<div style="clear: both"></div>
<table class="table table-responsive">
<tr>
<th><FONT SIZE=12>ID</FONT></th>
<td><FONT SIZE=14><?php echo $product->product_id; ?></FONT></td>
</tr>
$result is array of object I'm getting from a form. In below you can clearly see I'm chunking it to 3 more array and looping though individual objects and getting their details to html for example.
<tr>
<th><FONT SIZE=12>ID</FONT></th>
<td><FONT SIZE=14><?php echo $product->product_id; ?></FONT></td>
</tr>
I want to get the first object details let's say want get $product->product_name of first object of result array without going in loop how to achieve that.
here is complete view file code.
<!DOCTYPE html>
<html class="bg-black">
<head>
<meta charset="UTF-8">
<title><?php if(isset($title)) echo $title.' | '; ?> Sales agent management software (SAMS) </title>
<style>
body{
font-size: 9px;
margin: 20px;
}
th,td,p,div,table,h3{margin:0;padding:0}
#page { margin: 20px; }
.header{
border-bottom: 0px solid #dddddd;
text-align: center;
position: fixed; top: 0;
}
.footer { position: fixed; bottom: 0px; text-align: center }
.pagenum:before { content: counter(page); }
</style>
</head>
<body>
<?php
$usd = get_option('lkr_per_usd', 134);
?>
<div class="footer">
Page: <span class="pagenum"></span>, creation time : <?php echo date('l jS \of F Y h:i:s A') ?>, create by: <?php echo user_full_name(singleDbTableRow(loggedInUserData()['user_id'])); ?>, $ Rate : Rs. <?php echo $usd; ?> </div>
<br />
<div class="box-body">
<?php
$usd = get_option('lkr_per_usd', 134);
?>
<?php
$result = array_chunk($products->result_array(), 3);
foreach($result as $products){ ?>
<table style="width:100% style="page-break-after:always;" >
<tr>
<?php
foreach($products as $productArray){
$product = (object) $productArray;
echo '<td>';
?>
<div style="width: 100%; height: 210px; border: 1px solid #dddddd; margin: auto 5px 5px 0; padding: 5px;">
<div class="box-header">
<p class="box-title"><FONT SIZE=12><?php echo $product->product_name; ?></FONT></p>
</div>
<div style="height: 100px; text-align: center;">
<?php echo '<img src="'.'uploads/'. $product->photo.'" class="img-responsive" style="height:100px !important; width: 150px !important" />'; ?>
</div>
<div style="clear: both"></div>
<table class="table table-responsive">
<tr>
<th><FONT SIZE=12>ID</FONT></th>
<td><FONT SIZE=14><?php echo $product->product_id; ?></FONT></td>
</tr>
<tr>
<th><FONT SIZE=12>LKR</FONT></th>
<td><FONT SIZE=14><?php $lkr = get_selling_price($product);
echo number_format(round($lkr, get_option('round_precision')) ); ?></FONT>
</td>
</tr>
<tr>
<th> <FONT SIZE=12>US $</FONT></th>
<td><FONT SIZE=14><?php echo number_format(round(lkr_to_usd($lkr), get_option('round_precision')) ); ?></FONT></td>
</tr>
</table>
<?php $GLOBALS['a']= $product->product_id; ?>
</div>
</td>
<?php } ?>
</tr>
<?php } ?>
</table>
</div><!-- /.box-body -->
</body>
</body>
</html>
ok man as i said u need to change your way of writing codes but about your specific question use this:
$result = array('a', 'b', 'c', 'd', 'e');
reset($array);
$first = current($array);
you can check this:
http://php.net/manual/en/function.reset.php
http://php.net/manual/en/function.current.php
But still about your way of coding. u should soon go to MVC or such ways of programming so u should separate your view and coding logics
like u may have a page like view_profile.php which is going to show user's information. in regular coding u have this:
view_profile.php:
<?php session_start();
// you check sessions to see if the user is logged in and has the right to view this page.
// like:
if ($_SESSIONS['is_user_logged_in']){
$username=$_SESSIONS['username'];
$name=$_SESSIONS['name'];
// ....
}else{
header('location: ./login.php');// if user is not authenticated u redirect to login page
exit();// prevents the rest of codes to be shown and executed
}
?>
<html>
<head>
<title>View <?php echo $name; ?>'s profile</title>
</head>
<body>
<div>Name: <span><?echo $name; ?></span></div>
......
</body>
</html>
But in a better way u can do it like this:
you have files like
'view_profile.htm' // holds the HTML
'view_profile.php // holds the PHP logic
'inc.php' // holds some useful functions that help you in writing PHP logic
view_profile.htm
<html>
<head>
<title>View <?php echo $name; ?>'s profile</title>
</head>
<body>
<div>Name: <span><?echo $name; ?></span></div>
......
</body>
</html>
inc.php
<?php
function ses_start(){
if(!session_id()){
session_start();
}
}
function ses_get($key){
ses_start();
if(!empty($_SESSION[$key])){
return $_SESSION[$key];
}
return NULL;
}
function ses_set($key,$val){
$_SESSION[$key]=$val;
}
function is_user_loggedin(){
ses_start();
if(!empty(ses_get('is_user_loggedin')){
return true;
}
return false;
}
function go($to){
header('location: '.$to);
exit();
}
//and lots of useful functions that help u connect and work with data base.
view_profile.php
<?php
include('inc.php');
if(is_user_loggedin(){
$username=ses_get('username');
$name=ses_get('name');
//...
}else{
go('login.php);
}
include('view_profile.html); // and u call the .htm file that holds the HTML the view file)
?>
this was a simple sample of separating codes logic(php codes) from views(html tags)
and also u may search about MVC Model-View-Controller and try working with simple MVC frameworks.
I'm using Magento 1.7.0. I want to show latest ordered products on homepage sidebar. Almost everything is ready and working properly except its URL.
I don't know why products URL is repeating again and again. Products' images, it's name and price is showing correct only it's URL gets repeated for each product.
Each product have the same first product URL.
Here is the code
<style>
.productList { float:left; width:720px; }
.productList .product { background:#fff; border:1px solid #eedfa6; padding:3px; float:left; text-align:center; width: 182px; margin-bottom: 7px; height: 200px; }
.productList .product .cl { padding:0 0 0 0px; text-align:center;}
.productList .product .prodDetails {font-weight: bold;font-size: 12px; color: #2a2a28;text-align:center; padding:0 0 0 0px; }
.productList .product .prodDetails a{color: #d77932;}
.productList .product .prodDetails a:hover{color: #3d4d68 ;}
.productList .product .addCompare { text-align:center; clear:both; }
.productList .product .addWishlist {clear:both; text-align:center; }
}
</style>
<?php
$result = $this->getBestsellerProduct();
$itemPerRow = ($this->getItemsPerRow()) ? $this->getItemsPerRow() : 2 ;
//getting product model
$model = Mage::getModel('catalog/product');
$products_price = Mage::getStoreConfig('bestseller/general/products_price');
$review = Mage::getStoreConfig('bestseller/general/review');
?>
<div style="width:200px;float:right;">
<div class="sectionHead" style=""><h2><?php echo $this->getHeader(); ?></h2><div style="height: 25px;border-bottom: 2px solid #eedfa6 /*#DBDBDB;*/" class="hrline"></div></div>
<table border="0" cellpadding="0" cellspacing="0" class="productList" style="width:100px;">
<?php $i=0;
for($cnt = 0; $cnt<5; $cnt++){
$_product = $model->load($result[$cnt]); //getting product object for particular product id
?>
<tr>
<td class="product">
<div class="prodimage">
<!-- code added by Saurabh-->
<?php echo $_product->getProductUrl() ?>
<?php if ($_product->getExt_image_url()!=''){$srcImage=$_product->getExt_image_url();} else{$srcImage=$this->helper('catalog/image')->init($_product, 'small_image');} ?>
<!--saurabh code ended here-->
<a href="<?php echo $_product->getProductUrl() ; ?>" title="<?php echo $this->htmlEscape($_product->getName()) ?>">
<img src="<?php echo $srcImage; ?>" width="150" height="145" alt="<?php echo $this->htmlEscape($_product->getName()) ?>"/>
</a>
</div>
<div align="center">
<div class="prodDetails" align="center" style="width:175px;" >
<?php $_product_name= $_product->getName(); ?>
<?php $_short_product_name = substr($_product_name, 0, 40); ?>
<?php $_dot_product_name=$_short_product_name.'...' ; ?>
<?php echo $_dot_product_name ;?>
<?php if($review == 1)
{
$_product = Mage::getModel('catalog/product')->load($_product->getId());
echo $this->getReviewsSummaryHtml($_product, 'short');
}
if($products_price == 1)
{
$_product = Mage::getModel('catalog/product')->load($_product->getId());
echo $this->getPriceHtml($_product, true);
}
?>
</div>
<?php $addtocartval = $this->getAddToCart();
if($addtocartval == 1){
if($_product->isSaleable()): ?>
<button class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span><?php echo $this->__('Add to Cart') ?></span></button>
<?php else: ?>
<span class="out-of-stock"><?php echo $this->__('Out of stock') ?></span>
<?php endif; }?>
</div>
<div class="cl">
<?php $wishlists = $this->getActive();
if($wishlists == 1){
if ($this->helper('wishlist')->isAllow()) : ?>
<?php echo $this->__('Add to Wishlist') ?>
<?php endif; }?>
</div>
<div class="cl">
<?php $addtocompare = $this->getAddToCompare();
if($addtocompare==1){
if($_compareUrl=$this->getAddToCompareUrl($_product)): ?>
<?php echo $this->__('Add to Compare') ?>
<?php endif; }?>
</div>
</td>
</tr>
<?php
}
?>
</table>
</div>
First ,check $result[$cnt] is same for every time??
for($cnt = 0; $cnt<5; $cnt++){
// change code here
$_product = Mage::getModel('catalog/product')->load($result[$cnt]);
$my_product_url = $product->getProductUrl();
//or
$my_product_url=Mage::getResourceSingleton('catalog/product')
->getAttributeRawValue($result[$cnt], 'url_key', Mage::app()->getStore());
//or
$my_product_url=Mage::getUrl()''.$_product->getData('url_key').'.html';
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>';
?>