How to create buttons that increment and decrements values in PHP Codeinginter? - php

for a field Balance I want to create two buttons Add and Minus Buttons. This Field shows the current balance of Reseller. So now instead to adding some values in the text box i want to add buttons to its side so that i can increment the values in that field. Also i want to add the incremented value to existing(old) value. i know there are many example over the net but didn't worked for me so please help me.
My Balance Field :
<tr>
<td>Balance</td>
<td><?php echo form_input('balance', set_value('balance', $user->balance)); ?></td>
</tr>
The Increment Decrement Buttons :
<link href="<?php echo site_url('css/bootstrap.css'); ?>" rel="stylesheet">
<link href="<?php echo site_url('css/add.css'); ?>" rel="stylesheet">
<link href="<?php echo site_url('css/datepicker.css'); ?>" rel="stylesheet">
<link href="<?php echo site_url('css/jquery-ui.css'); ?>" rel="stylesheet">
<link href="<?php echo site_url('css/jquery-ui.min.css'); ?>" rel="stylesheet">
<link href="<?php echo site_url('css/jquery-ui.structure.css'); ?>" rel="stylesheet">
<link href="<?php echo site_url('css/jquery-ui.structure.min.css'); ?>" rel="stylesheet">
<link href="<?php echo site_url('css/jquery-ui.theme.css'); ?>" rel="stylesheet">
<link href="<?php echo site_url('css/jquery-ui.theme.min.css'); ?>" rel="stylesheet">
<link href="<?php echo site_url('/bower_components/metisMenu/dist/metisMenu.min.css'); ?>" rel="stylesheet">
<link href="<?php echo site_url('/dist/css/timeline.css'); ?>" rel="stylesheet">
<link href="<?php echo site_url('/dist/css/sb-admin-2.css'); ?>" rel="stylesheet">
<link href="<?php echo site_url('/bower_components/morrisjs/morris.css'); ?>" rel="stylesheet">
<link href="<?php echo site_url('bower_components/font-awesome/css/font-awesome.min.css'); ?>" rel="stylesheet">
<link href="<?php echo site_url('bower_components/datatables-plugins/integration/bootstrap/3/dataTables.bootstrap.css'); ?>" rel="stylesheet">
<link href="<?php echo site_url('bower_components/metisMenu/dist/metisMenu.min.css'); ?>" rel="stylesheet">
<link href="<?php echo site_url('bower_components/datatables-responsive/css/dataTables.responsive.css'); ?>" rel="stylesheet">
<link href="<?php echo site_url('/bower_components/bootstrap/dist/css/bootstrap.min.css'); ?>" rel="stylesheet">
<link rel="shortcut icon" href="<?php echo site_url('img/favicon.ico'); ?>" type="image/x-icon" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>
$(function()
{
$('#spinnerInput').spinner();
});
</script>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script src="<?php echo site_url('js/bootstrap.min.js'); ?>"></script>
<script src="<?php echo site_url('css/external/jquery/jquery.js'); ?>"></script>
<script src="<?php echo site_url('bower_components/metisMenu/dist/metisMenu.min.js'); ?>"></script>
<script src="<?php echo site_url('/bower_components/datatables/media/js/jquery.dataTables.min.js'); ?>"></script>
<script src="<?php echo site_url('/bower_components/datatables-plugins/integration/bootstrap/3/dataTables.bootstrap.min.js'); ?>"></script>
<script src="<?php echo site_url('/dist/js/sb-admin-2.js'); ?>"></script>
<script src="<?php echo site_url('bower_components/bootstrap/dist/js/bootstrap.min.js');?>"></script>
<script src="<?php echo site_url('bower_components/metisMenu/dist/metisMenu.min.js');?>"></script>
<script src="<?php echo site_url('bower_components/raphael/raphael-min.js');?>"></script>
<script src="<?php echo site_url('js/morris-data.js');?>"></script>
<script src="<?php echo site_url('dist/js/sb-admin-2.js');?>"></script>
<script>
$(document).ready(function() {
$('#dataTables-example').DataTable({
responsive: true
});
});
</script>

You need to add jquery-ui js and css files along with required images. Please download the files and images from below urls
JS - http://code.jquery.com/ui/1.9.2/jquery-ui.js
CSS - http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css
images -
https://code.jquery.com/ui/1.11.4/themes/smoothness/images/ui-icons_888888_256x240.png
https://code.jquery.com/ui/1.11.4/themes/smoothness/images/ui-icons_454545_256x240.png

Related

Change style.css by changing language in php

Does anyone know how to use condition in CSS?
I'm using PHP Script The thing is that I have 4 files with these names "style.css","style-rtl.css","bootstrap.min.css","bootstrap-rtl.min.css" that sometimes may be in RTL language.
So I want some sort of PHP code or any other solution that can detect if the language is Ar and set the direction to RTL with style-rtl.css & bootstrap-rtl.min.css , else language is En set direction to LTR and use style.css & bootstrap.min.css .
Here is some header.php code:
<!-- Bootstrap core CSS -->
<link href="<?php echo $this->config["url"] ?>/static/css/bootstrap.min.css" rel="stylesheet">
<link href="<?php echo $this->config["url"] ?>/static/css/bootstrap-rtl.min.css" rel="stylesheet">
<!-- Component CSS -->
<link rel="stylesheet" type="text/css" href="<?php echo $this->config["url"] ?>/themes/<?php echo $this->config["theme"] ?>/style.css">
<link rel="stylesheet" type="text/css" href="<?php echo $this->config["url"] ?>/themes/<?php echo $this->config["theme"] ?>/style-rtl.css">
<link rel="stylesheet" type="text/css" href="<?php echo $this->config["url"] ?>/static/css/components.min.css">
i solved this problem with :
<?PHP
if(isset($_SESSION['lang']))
{
switch($_SESSION['lang']):
case 'eng':
// LTR Style
?>
<link href="<?php echo $this->config["url"] ?>/static/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="<?php echo $this->config["url"] ?>/themes/<?php echo $this->config["theme"] ?>/style.css">
<?PHP
break;
case 'ar':
// RTL Style
?>
<link href="<?php echo $this->config["url"] ?>/static/css/bootstrap-rtl.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="<?php echo $this->config["url"] ?>/themes/<?php echo $this->config["theme"] ?>/style-rtl.css">
<?PHP
break;
default:
?>
<link href="<?php echo $this->config["url"] ?>/static/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="<?php echo $this->config["url"] ?>/themes/<?php echo $this->config["theme"] ?>/style.css">
<?PHP
endswitch;
}
?>

when redirected to a page the css files , js , images etc aren't loading

I am new in codeigniter. actual page has no problems but when redirected to a page the css files , js , images etc aren't loading
<script src="<?php echo site_url('resource/js/bootstrap.js'); ?>"></script>
<link href="<?php echo site_url('resource/css/default.css'); ?>" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href=" <?php echo site_url('resource/css/tab.css'); ?>" type="text/css" media="screen">
<link rel="stylesheet" href="<?php echo site_url('resource/css/mob.css'); ?>" type="text/css" media="screen">
<link href="<?php echo site_url('resource/css/nav.css'); ?>" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="<?php echo site_url('resource/css/style.css'); ?>" type="text/css" media="screen" />
<link rel="stylesheet" href="<?php echo site_url('resource/font/font.css'); ?>" type="text/css" media="screen">
I think you have to replace site_url() with base_url()
echo base_url(); // http://example.com/website
echo site_url(); // http://example.com/website/index.php

nivo slider image dispaly in template but do not display in CodeIgniter what is the reason?

1.Image of nivo slider display in my template . But when I use it into codeIgniter then it can not display.
2.Others content of template shows but only image does not show .
3.With firebug I saw when nivoslider div act then it show image tag where visibility:hidden and background show url of image not found.
I am newbie . Please help me.
Master page :
This is code:
<title>This is Title</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap -->
<link href="<?php echo base_url();?>css/bootstrap.min.css" rel="stylesheet" media="screen">
<link href="<?php echo base_url();?>css/bootstrap-theme.min.css" rel="stylesheet" media="screen">
<!-- Amazing Mobile Menu CSS -->
<link href="<?php echo base_url();?>css/jquery.fs.naver.css" rel="stylesheet" type="text/css" />
<!-- News Tickr CSS -->
<link href="<?php echo base_url();?>css/ticker-style.css" rel="stylesheet" type="text/css" />
<!-- Bebas Webfont -->
<link href="<?php echo base_url();?>fonts/stylesheet.css" rel="stylesheet" media="screen">
<!-- Nivo Slider CSS -->
<link rel="stylesheet" href="<?php echo base_url();?>css/themes/default/default.css" type="text/css" media="screen" />
<link rel="stylesheet" href="<?php echo base_url();?>css/nivo-slider.css" type="text/css" media="screen" />
<!-- Main CSS -->
<link href="<?php echo base_url();?>css/style.css" rel="stylesheet" media="screen">
<!-- Responsive Framework -->
<link href="<?php echo base_url();?>css/responsive.css" rel="stylesheet" media="screen">
**html code for nivoslider:**
<div id="slider" class="nivoSlider">
<img src="<?php echo base_url();?>img/toystory.jpg" alt="" />
<img src="<?php echo base_url();?>img/up.jpg" alt="" />
<img src="<?php echo base_url();?>img/walle.jpg" alt="" />
<img src="<?php echo base_url();?>img/nemo.jpg" title="#htmlcaption" alt="" />
</div>
''''''''''''''''''''''''''''
''''''''''''''''''''''''''' **others code here**![enter image description here][1]
this code for script:
<script src="http://code.jquery.com/jquery-1.9.0.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<script src="<?php echo base_url();?>js/jquery.nivo.slider.pack.js"></script>
<script type="text/javascript">
$(window).load(function() {
$('#slider').nivoSlider({
controlNav: false
});
});
</script>
<script src="<?php echo base_url();?>js/jquery.ticker.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$('#js-news').ticker();
});
</script>
<script src="<?php echo base_url();?>js/jquery.fs.naver.min.js"></script>
<script type="text/javascript">
$("nav").naver({
animated: true
});
</script>
<script src="<?php echo base_url();?>js/bootstrap.min.js"></script>
[1]: http://i.stack.imgur.com/JsaIJ.png
Change
<?php echo base_url();?>img/toystory.jpg
into
<?php echo base_url();?>/img/toystory.jpg
(note the slash).
Or even better: remove all <?php echo base_url();?> and add in your head:
<base href="/" /> or <base href="<?php echo base_url();?>/" />

PHP How right replace element in page?

Good day.
We have test.php with next code:
<link rel="stylesheet" type="text/css" href="<?php echo STYLE_TEST1; ?>" />
<link rel="stylesheet" type="text/css" href="<?php echo STYLE_TEST2; ?>" />
<div class="container">
<p class="test">{Text}</p>
</div>
<!-- STYLE_TEST1 and STYLE_TEST2 - set in define as "/css/styletest1.css" and "/css/styletest2.css" -->
and index.php with code:
$content = file_get_contents("test.php");
$content = ereg_replace("{Text}", 'hello', $content);
echo $content;
in result we get code:
<link rel="stylesheet" type="text/css" href="<?php echo STYLE_TEST1; ?>" />
<link rel="stylesheet" type="text/css" href="<?php echo STYLE_TEST2; ?>" />
<div class="container">
<p class="test">{Text}</p>
</div>
we have problem with styles, becose echo $content; print <?php echo STYLE_TEST1; ?> and <?php echo STYLE_TEST2; ?> and not replace on values which set in define for this elements(not change on "/css/styletest1.css" and "/css/styletest2.css").
Tell me please how right make replace?
P.S.: we need that styles was include in file test.php, ie file test.php should have lines:
<link rel="stylesheet" type="text/css" href="<?php echo STYLE_TEST1; ?>" />
<link rel="stylesheet" type="text/css" href="<?php echo STYLE_TEST2; ?>" />
Thanks all for help!
This is the best decision for me on my question
function getTemplate($file) {
ob_start(); // start output buffer
include $file;
$template = ob_get_contents(); // get contents of buffer
ob_end_clean();
return $template;
}
$content = getTemplate("test.php");
$content = ereg_replace("{Text}", 'hello', $content);
echo $content;
A way to fix this is to make it a variable....
just make sure you have
define("STYLE_TEST1", "/css/styletest1.css");
define("STYLE_TEST2", "/css/styletest2.css");
test.php
<link rel="stylesheet" type="text/css" href="<?php echo STYLE_TEST1; ?>" />
<link rel="stylesheet" type="text/css" href="<?php echo STYLE_TEST2; ?>" />
<div class="container">
<p class="test">{<?=$variable?>}</p>
</div>
<!-- STYLE_TEST1 and STYLE_TEST2 - set in define as "/css/styletest1.css" and "/css/styletest2.css" -->
index.php
$variable = 'hello';
include 'test.php';
The result will be:
<link rel="stylesheet" type="text/css" href="/css/styletest1.css" />
<link rel="stylesheet" type="text/css" href="/css/styletest2.css" />
<div class="container">
<p class="test">{hello}</p>
</div>

kendoui grid is not showing data?

i have used kendoui grid in my codeigniter web application.
The grid is showingup, but there no data loaded in that.
Here is the details of what i have done.
i have used the query and did echoed it in file in json encode
The output of echo is.
{"data":[{"Username":"admin","FirstName":"System","MiddleNames":"Default","LastName":"Administrator","City":"Sakhakot","Email":"kifayat#zorkif.com"},{"Username":"guest","FirstName":"System","MiddleNames":"Default","LastName":"Guest","City":"Peshawar","Email":"kifayat#zorkif.com"}]}
the location of this data file in which i have done the above echo. is
http://localhost:12/projects/zorkif_nextgen/user_management/manage_users/list_view/
here is my view file in which i want to show the grid.
<?php
/**
* Created by JetBrains PhpStorm.
* User: Kill3rCoder-Lapi
* Date: 3/21/13
* Time: 10:58 AM
* To change this template use File | Settings | File Templates.
*/
?>
<div id="grid"></div>
<script>
$(function(){
$("#grid").kendoGrid({
dataSource:{
read: {
read: "<?php echo base_url() ?>/index.php/user_management/manage_users/list_view/"
},
schema:{
data: "data"
}
},
columns: [
{ field: "Username",
title:"Username"
},
{ field: "FirstName",
title:"First Name"
},
{field:"MiddleNames"},
{field:"LastName"},
{field:"City"},
{field:"Email"}
]
});
});
</script>
This is my Head Section for of my application.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta charset="utf-8">
<title>Zorkif Business One Next Generation</title>
<link href="<?php echo base_url('kendo_ui/styles/kendo.common.min.css'); ?>" rel="stylesheet">
<link href="<?php echo base_url('kendo_ui/styles/kendo.default.min.css'); ?>" rel="stylesheet">
<script src="<?php echo base_url('kendo_ui/js/kendo.web.min.js'); ?>"></script>
<script src="<?php echo base_url('kendo_ui/js/kendo.grid.min.js'); ?>"></script>
<link href="<?php echo base_url('styles/zorkif_fluid_main.css'); ?>" rel="stylesheet" type="text/css">
<!-- Designed By Zorkif.com Team -->
<link href="<?php echo base_url('styles/messages.css'); ?>" rel="stylesheet" type="text/css">
<!-- The main message boxes appearing on the top of the page -->
<link href="<?php echo base_url('styles/header.css'); ?>" rel="stylesheet" type="text/css">
<!-- To style the header of the page -->
<link href="<?php echo base_url('styles/tab_bar.css'); ?>" rel="stylesheet" type="text/css">
<!-- To style the Tabs Menu and the Title Section of the page -->
<link href="<?php echo base_url('styles/action_buttons.css'); ?>" rel="stylesheet" type="text/css">
<!-- To style the action buttons and search box of the page -->
<link href="<?php echo base_url('styles/footer.css'); ?>" rel="stylesheet" type="text/css">
<!-- To style the header of the page -->
<link href="<?php echo base_url('styles/zorkif_slider.css'); ?>" rel="stylesheet" type="text/css">
<!-- To style the header of the page -->
<link href="<?php echo base_url('styles/login_form.css'); ?>" rel="stylesheet" type="text/css">
<!-- To style the header of the page -->
<link href="<?php echo base_url('styles/forms.css'); ?>" rel="stylesheet" type="text/css">
<!-- To style the form elements in the page -->
<link href="<?php echo base_url('styles/tables.css'); ?>" rel="stylesheet" type="text/css">
<!-- To style the default tables and data view and data entry tables in page -->
<link href="<?php echo base_url('styles/tiles_cpanel.css'); ?>" rel="stylesheet" type="text/css">
<!-- To style the information Tiles tabs for the cpanel -->
<link href="<?php echo base_url('styles/page_columns.css'); ?>" rel="stylesheet" type="text/css">
<!-- The file is used to privide column based division of the page design -->
<script src="<?php echo base_url('scripts/jquery-1.8.3.min.js'); ?>" type="text/javascript"></script>
<!--<script type="text/javascript" src="<?php /*base_url('scripts/cssrefreshNONE.js'); */?>"></script><!-- for Develoment Perpose Only and must be removed in the production version -->
-->
<!-- Start of Accordion Menu -->
<link href="<?php echo base_url('scripts/horz_accordion_menu/accordion_menu.css'); ?>" rel="stylesheet" type="text/css">
<script src="<?php echo base_url('scripts/horz_accordion_menu/accordion_menu.js'); ?>" type="text/javascript"></script>
<!-- End of Accordion Menu -->
<!-- Nivo Image Slider -->
<link rel="stylesheet" href="<?php echo base_url('scripts/nivo-slider/themes/default/default.css'); ?>" type="text/css" media="screen" />
<link rel="stylesheet" href="<?php echo base_url('scripts/nivo-slider/nivo-slider.css'); ?>" type="text/css" media="screen" />
<!-- End of Image Slider -->
<link rel="shortcut icon" href="<?php echo base_url('favicon.ico'); ?>" />
<!-- Kendo UI Start -->
<!-- Kendo UI Web styles -->
<link href="<?php echo base_url('kendo_ui/styles/kendo.common.min.css'); ?>" type="text/css" />
<link href="<?php echo base_url('kendo_ui/styles/kendo.default.min.css'); ?>" type="text/css" />
<!-- Kendo UI Web scripts -->
<script src="<?php echo base_url('kendo_ui/js/jquery.min.js'); ?>" type="text/javascript"></script>
<script src="<?php echo base_url('kendo_ui/js/kendo.web.min.js'); ?>" type="text/javascript"></script>
</head>
So now i cant figure out where is it i am stuck???
anyone with Kendoui expertise??
You wrote:
read: {
read: ...
}
when it should be:
transport: {
read: ...
}
By the way, did you realize that are including KendoUI twice? also, the first time that you include it you include Kendo not having include jQuery before. I don't think that that will work

Categories