I use framework:
CodeIgniter
I try display values from enrol table. Connetcion with DB working correct etc. Because standard app function in this way working correct. I try add my custom own code but something went wrong and result is empty.
I try combinate in this way:
<?php
$enrol_history = $this->db->get_where('enrol', array('active_shop' => $active_shop, 'monthly_subscription_fee' => $monthly_subscription_fee))->row_array();
?>
<?php echo $active_shop['active_shop']; ?>
<?php echo $enrol_history['monthly_subscription_fee']; ?>
<?php echo $active_shop ?>
<?php echo $monthly_subscription_fee ?>
Everytime empty result.
update:
I also try:
Crud_model.php
public function get_installation_details($monthly_subscription_fee = "")
{
return $this->db->get_where('enrol', array('monthly_subscription_fee' => $monthly_subscription_fee));
}
code:
<?php $installation_details = $this->crud_model->get_installation_details($monthly_subscription_fee)->row_array(); ?>
<?php echo $installation_details['monthly_subscription_fee']; ?>
update:
<?php
$enrol_history = $this->db->get_where('enrol', array('active_shop' => $enrol['active_shop'], 'monthly_subscription_fee' => $enrol['monthly_subscription_fee'],))->row_array();
?>
<?php echo $enrol['monthly_subscription_fee']; ?>
<?php echo $enrol['active_shop']; ?>
This is correct. Because in admin panel I can get in this way this values from DB. But in frontend I cannot do it...
Related
I'm trying to use the php get. everthing is working find exept the include page.
it's adding 1 at the end of include content
any ide how do i ride that?
example:
I love norway
I love norway1
Code:
<?php
if($_GET['boy'] == 'zabi') $zabkas = 'it is Zabi';
if($_GET['girl'] == 'veronka') $verona = 'It is veronka';
if($_GET['place'] == 'norway') $norge = include('norway.php');
?>
<?php echo $zabkas ?>
<?php echo $verona ?>
<?php echo $norge ?>
We should use file_get_contents, instead of include.
$norge = file_get_contents("norway.php");
Use the output buffer functions to capture the output from the included script.
<?php
if($_GET['boy'] == 'zabi') $zabkas = 'it is Zabi';
if($_GET['girl'] == 'veronka') $verona = 'It is veronka';
if($_GET['place'] == 'norway') {
ob_start();
include("norway.php");
$norge = ob_get_clean();
}
?>
<?php echo $zabkas ?>
<?php echo $verona ?>
<?php echo $norge ?>
is it possible to have different headers on each page?
I'm currently using this code which works perfectly
<?php if(is_front_page()):?>
<?php echo do_shortcode('[myiamge1]'); ?>
<?php endif;?>
Now I tried to use this code and it doesnt work
<?php if(is_front_page()):?>
<?php echo do_shortcode('[myiamge1]'); ?>
else { ?> (is_page('Contact')){
echo '<img src="image5.jpg" />';
}
<?php endif;?>
Any ideas?
I know nothing about Wordpress - never used it but the above doesn't look right. Is there a reason whya more traditional style syntax is not adopted - more akin to this:
<?php
if( is_front_page() ){
echo do_shortcode('[myiamge1]');
} elseif( is_page('Contact') ){
echo '<img src="image5.jpg" />';
} else {
/*banana for scale - do something else*/
}
?>
I'm using this php mobile detect script https://github.com/serbanghita/Mobile-Detect
And I have singled out this code that I want to use, however I want to throw in an 'else' option, but I seem unable to do so.
This is the code
<?php $check = $detect->isMobile(); if($check): ?>
Hello you're on a phone
<?php endif; ?>
This is what I want to achieve
<?php $check = $detect->isMobile(); if($check): ?>
You are phone
<? else ?>
You're something else
<?php endif; ?>
But when I do it throws up a Parse error: syntax error
You can try this simpler syntax:
<?php $check = $detect->isMobile(); if($check){ ?>
You are phone
<? } else { ?>
You're something else
<?php } ?>
The above is better to understand, but you can use this too:
<?php $check = $detect->isMobile(); if($check): ?>
You are phone
<? else: ?>
You're something else
<?php endif; ?>
I would rather say, use the first part . Though the second syntax is good, but the first is easier to understand.
You forgot : after else on 3rd line,
<?php $check = $detect->isMobile(); if($check): ?>
You are phone
<? else: ?> // here
You're something else
<?php endif; ?>
I am using the WordPress plugin WP-PostViews to display the number of views a post has. I am using this code and it works great:
<?php if(function_exists('the_views')) { the_views(); }?>
The thing I want to do is to use this number of post views as a variable but I can't get it working. So far I have tried:
<?php if(function_exists('the_views')) { $variable = the_views(); } ?>
and
<?php if(function_exists('the_views')) { $variable = the_views(); } else { $var = 0; } ?>
No success so far. Does anyone have suggestions?
By default the_views() echos instead of returns. You can get a return by setting the first argument to false. Example:
<?php if(function_exists('the_views')) { $variable = the_views(false); } ?>
I'm trying to implement SlickGrid on the edit page of a CakePHP project, and when the page loads I get this error in the javascript console:
slick.grid.js:2173TypeError:'Slick.Editors.Text is not a constructor' (evaluating 'new (editor || getEditor(activeRow, activeCell))')
The data renders correctly in the grid on my page, but when I click on a cell to edit it, it just turns white and I can't type anything. If I click on another cell, that cell will turn white and the first one will stay white.
Here is my php/jQuery code:
<?php echo $this->Html->script("/js/slickgrid/lib/jquery-1.7.min.js"); ?>
<?php echo $this->Html->script("/js/slickgrid/lib/jquery.event.drag-2.0.min.js"); ?>
<?php echo $this->Html->script("/js/slickgrid/lib/jquery-ui-1.8.16.custom.min.js"); ?>
<?php echo $this->Html->script("/js/slickgrid/slick.core.js"); ?>
<?php echo $this->Html->script("/js/slickgrid/slick.grid.js"); ?>
<?php echo $this->Html->script("/js/slickgrid/slick.editors.js"); ?>
<?php echo $this->Html->script("/js/slickgrid/slick.formatters.js"); ?>
<?php echo $this->Html->script("/js/slickgrid/slick.dataview.js"); ?>
<?php echo $this->Html->script("/js/slickgrid/plugins/slick.cellselectionmodel.js"); ?>
<?php echo $this->Html->script("/js/slickgrid/plugins/slick.cellrangedecorator.js"); ?>
<?php echo $this->Html->script("/js/slickgrid/plugins/slick.cellrangeselector.js"); ?>
<?php echo $this->Html->script("/js/slickgrid/plugins/slick.rowselectionmodel.js"); ?>
<?php // Setup rows and cols array for grid
$columns = array();
foreach($route['Stop'] as $stop) {
$columns[] = array( "name" => $stop['name'],
"field" => $stop['id'],
"id" => $stop['id'],
"editor" => "Slick.Editors.Text");
}
$tripId = 1;
$thisTrip['id'] = $tripId;
foreach($route['RouteTrip'] as $routeTrip) {
if($routeTrip['trip_id'] != $tripId) {
$rows[] = $thisTrip;
$tripId = $routeTrip['trip_id'];
$thisTrip['id'] = $tripId;
}
else {
$thisTrip[$routeTrip['stop_id']] = $routeTrip['time'];
}
}
?>
<?php
echo $this->Html->scriptBlock('
var rows = '.json_encode($rows).';
var columns = '.json_encode($columns).';
var options = { rowHeight:21,
defaultColumnWidth:100,
editable:true,
enableAddRow:true,
enableCellNavigation:true,
asyncEditorLoading:false,
autoHeight:true,
autoEdit:true
};
slickgrid = new Slick.Grid($("#scheduleTable"), rows, columns, options);
slickgrid.setSelectionModel(new Slick.CellSelectionModel());
slickgrid.updateRowCount();
slickgrid.render();
');
?>
The $rows and $columns are correctly formatted, and each column has an "editor" attribute with "Slick.Editors.Text" as its value.
Help?
I have also got this error initially when i started working with slickgrid.
The error is because you have specified the editor as string and not as a class.
So, remove the double quotes in "editor" => "Slick.Editors.Text" and give as "editor" => Slick.Editors.Text
This solved the error for me. Hope this solution will solve yours too.
Include the slick.editors.js file.
Also, make sure that the editor is being specified as a class, not as a string (I'm not familiar with PHP, so it's not obvious to me from the source code, but I suspect that's the case).