Posts

Showing posts from December, 2018

first li active in while loop in php mysql

<?php   $sql="SELECT * from `shiksha_testimonial` where featured=1 order by testimonial_id DESC";    $result=mysqli_query($con,$sql);    $num_rows=mysqli_num_rows($result);    if($num_rows > 0)    {    $i=0;   while($row=mysqli_fetch_array($result))                     {                    ?>                <div class="item carousel-item <?php if($i==0) {      $i=1;      echo 'active'; } ?>">                 <div class="img-box"><img src="<?php echo $base_url ?>/uploads/testimonial/<?php echo $row['client_img']; ?>" alt=""></div>                 <p class="testimonial"><?php echo mb...

create unique slug in php mysql

$slug = ''; $slug = preg_replace('/[^a-z0-9]+/i', '-', trim(strtolower($_POST["business_title"])));  $query = "SELECT `listing_slug` FROM `listing` WHERE listing_slug LIKE '$slug%'";   $slug_result=mysqli_query($con,$query);   $slug_num=mysqli_num_rows($slug_result);   if($slug_num > 0)   {  while ($row = mysqli_fetch_assoc($slug_result)) {      $data[] = $row['listing_slug'];     } if(in_array($slug, $data))    {     $count = 0;     while( in_array( ($slug . '-' . ++$count ), $data) );     $slug = $slug . '-' . $count;    }   }

php logical programs

https://www.letsknowit.com/php-programming-questions

search page with pagination in php

<?php ob_start(); include_once('common/header.php'); $search='';    $search=$_REQUEST['search']; $category=$_REQUEST['category']; $location=$_REQUEST['location']; ?>   <!----main-info--->   <section id="food-category">     <div class="block remove-top">       <div class="container m-sis-back">         <div class="row">           <div class="col-lg-3">             <div class="adds"> <a href="#"><img src="ap-img/about-stud.png" class="img-responsive"></a> </div>           </div>           <div class="col-lg-9">             <div class="ml-placessec godouble golist">               <div class="row">   <?php $perpage = 2; if(isset($_G...

search with multiple fields in php

<?php   include_once('common/header.php'); $search='';    $search=$_REQUEST['search']; $category=$_REQUEST['category']; $location=$_REQUEST['location']; //$sql1="SELECT `listing`.*, listing_category.cat_id, listing_category.categoryslug from `listing` left join listing_category on listing.category_id=listing_category.cat_id WHERE listing.listing_title LIKE '%".$search."%' AND listing_category.categoryslug LIKE '%".$category."%' AND listing.business_address LIKE '%".$location."%' order by listing.date_added DESC"; $sql1="SELECT `listing`.*, listing_category.cat_id, listing_category.categoryslug from `listing` left join listing_category on listing.category_id=listing_category.cat_id WHERE listing.listing_title LIKE '%".$search."%' AND listing_category.categoryslug LIKE '%".$category."%' AND (listing.business_address LIKE '%...

url rewrite for dynamic category page using htaccess

http://shikshaadhar.com/category.php?category=institutes to http://shikshaadhar.com/colleges.html Sample code below: <IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^([^/]*)\.html$ /category.php?category=$1 [L] </IfModule>

blog with source code in ci

https://bitbucket.org/richardwo/coding-test-blog-ci/src/39eaf781c512507fd87452100a9f38bb656e3635?at=master

get country name by ip address in php

<?php function getLocationInfoByIp(){     $client  = @$_SERVER['HTTP_CLIENT_IP'];     $forward = @$_SERVER['HTTP_X_FORWARDED_ FOR'];     $remote  = @$_SERVER['REMOTE_ADDR'];     $result  = array('country'=>'', 'countrycode'=>'', 'city'=>'');     if(filter_var($client, FILTER_VALIDATE_IP)){         $ip = $client;     }elseif(filter_var($forward, FILTER_VALIDATE_IP)){         $ip = $forward;     }else{         $ip = $remote;     }     $ip_data = @json_decode(file_get_ contents(" http://www. geoplugin.net/json.gp?ip= ".$ ip));         if($ip_data && $ip_data->geoplugin_ countryName != null){         $result['country'] = $ip_data->geoplugin_ countryName;         $result['countrycode'] = $ip_data->geoplu...

rewrite url using htaccess file?

I want to rewrite this url http : //localhost/vector-svn/demo.php rewrite to http : //localhost/vector-svn/demo Answer to my own question !! This works for url rewriting !! RewriteEngine on RewriteCond %{ REQUEST_FILENAME } !- d RewriteCond %{ REQUEST_FILENAME } \.php - f RewriteRule ^(.*) $ $1 . php

countdown timer using php and javascript.

<?php  $date=date_create("2018-12-07 13:06:01"); date_add($date,date_interval_create_from_date_string("30 days")); // $listing_expire_time= date_format($date,"Y-m-d H:i:s");  $listing_expire_time= date_format($date,"M j, Y H:i:s");   //echo $today = date("M j, Y g:i a");              ?> <p id="demo"></p> <script> var countDownDate = new Date("<?php echo $listing_expire_time; ?>").getTime(); var x = setInterval(function() { var now = new Date().getTime(); var distance = countDownDate - now; var days = Math.floor(distance / (1000 * 60 * 60 * 24)); var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)); var seconds = Math.floor((distance % (1000 * 60)) / 1000);    document.getElementById("demo").innerHTML = days + "d " + hours + "h "     + minute...