Posts

Showing posts with the label PHP

Url encode decode anchor links with AngularJS PHP

Image
I had following link  in one of rest call which lead to SQL unexpected result due to & symbol. http://localhost/test/getDsv?$top=32&$skip=0&var=HR & Admin&com= Query has only considered  var=HR   only  which leads to unexpected results. My front end is anguler and I can encode the perticulter paramenter with  window . encodeURIComponent() Ref : http://stackoverflow.com/questions/11294107/how-can-i-send-the-ampersand-character-via-ajax To Decode it at PHP side there in nothing to do ,although there are lot of posts ,which indicate decoding. $this->_request['var']; http://stackoverflow.com/questions/11294107/how-can-i-send-the-ampersand-character-via-ajax

PHP Write Echo content to file

You can get the echo content to variable as fallows ob_start (); echo '<html>' ; echo '<div>' ; echo 'TEST PRINT' ; echo '</div>' ; echo '</html>' ; $content = ob_get_clean (); Write the echo content to file can achieve as fallows $fp = fopen ( $_SERVER [ 'DOCUMENT_ROOT' ] . "/test . html" , "wb" ); fwrite ( $fp , $content ); fclose ( $fp );

jQuery Datatable with the ajax Json String

Image
You  can integrate  jQuery Datatable with the ajax source in following way. Download Realse Packages  https://datatables.net/download/ Import JS and CSS <script src="public/js/jquery.dataTables.min.js" type="text/javascript"></script>  <link href="public/css/jquery.dataTables.min.css" rel="stylesheet" type="text/css"/> HTML    <div class="col-md-12 table-responsive">                        <!-- <table id="table" class="table  table-bordered table-striped ">-->    <table id="table" class="table table-striped table-hover dt-responsive display nowrap" width="100%" cellspacing="0" >                             <thead>                                 <tr>...

Create Radio Button Group - PHP

In here you can crate a radio button  group dynamically. I have used the Array List Object which has the ID and FULL_NAME columan. <?php $i=0; foreach ($this->approverList as $key => $category) { if($i==0){ echo("<input type='radio'  . name='Group' value='" . $category->ID . "' checked>" . $category->FULL_NAME . " <br>"); }else{ echo("<input type='radio'  name='Group' value='" . $category->ID . "'>" . $category->FULL_NAME . " <br>"); } $i++; } ?> In order to set the Checked value dynamically .Use the following method. <input disabled type="radio" name="carrytype"  value="EMPLOYEE" <?php echo ([DBValue From Object]=='EMPLOYEE' ? 'checked' : '');?> > Employee