Transaction in PHP Mysql

This is how easily you can implement tractions in mysqli and PHP. $link = mysqli_connect(‘localhost’,’root’,”,’test’); // Check connection if (mysqli_connect_errno()) { die(‘error’); } mysqli_autocommit($link, FALSE); //disable autocommit $query=”insert into tb1 (username,pwd) values(‘pp’,’sdsd’)”; $queryres=mysqli_query($link, $query); if(!$queryres) { echo “error first query”;…

Get Project Path with Protocol

Here is how you can absolute project url with for http and htts both:: $protocol = stripos($_SERVER[‘SERVER_PROTOCOL’],’https’) === true ? ‘https://’ : ‘http://’; echo $protocol.$_SERVER[‘HTTP_HOST’].$_SERVER[‘PHP_SELF’];

Pagination in single Query

What people normally do in the code? Example: //query to count total records $result = mysqli_query($conn,”SELECT COUNT(*) total FROM test”); //getting count if($result) { $totalRows=mysqli_num_rows($result); if($totalRows==1) { $resultData=mysqli_fetch_assoc($result); $total=$resultData[‘total’]; //total count in a variable } else{ echo “No rows found”;…

Calling Ajax In WordPress

Here is the code for calling ajax functions in WordPress. //javascript function function test() { var sitename = “http://localhost/test/”; //getdynamic var ajax_path = “/wp-admin/admin-ajax.php”; var name=$(‘#name’).val(); var cell=’9999999999′; $.ajax({ type : “POST”, async : false, url : sitename + ajax_path,…

Page 7 of 7« First...34567