Top Questions

  • 2.9 Years

    • Category : Mysql
    • Location : Chandigarh
    • Posted On : Feb 25, 2017

    You can match two column value using this code

     SELECT * FROM booking WHERE id='1' AND (STR_TO_DATE(`from`, '%d-%m-%Y') <='2017-02-24' AND (STR_TO_DATE(`till`, '%d-%m-%Y') >='2017-02-24')) AND service='test' AND status='0'
  • 2.9 Years

    • Category : Jquery
    • Location : Chandigarh
    • Posted On : Feb 12, 2017

    JQuery Ajax form using boostrap validation

     $(document).on('submit','#formid',function(){
     $(this).formValidation({
                                framework: 'bootstrap',
                                fields: {
                                    name: {
                                        validators: {
                                            notEmpty: {
                                                message: 'The name is required'
                                            }
                                        }
                                    },
                                    email: {
                                        validators: {
                                            notEmpty: {
                                                message: 'The email is required'
                                            }
                                        }
                                    },
                                    password: {
                                        validators: {
                                            notEmpty: {
                                                message: 'The password is required'
                                            }
                                        }
                                    },
                                }
                            })
                            .on('success.form.fv', function(e) {
                                e.preventDefault();
                               var Formdata=$(this).serialize();
                                $.ajax({
                                    type: "POST",
                                    url: '', //add page url here
                                    data: Formdata, //send data from here,
                                    success: function(data) {
                                        alert(data);
                                    }
                                });
                            });
                     });
     
  • 2.11 Years

    • Category : Jquery
    • Location : Chandigarh, India
    • Posted On : Feb 4, 2019

    If you want to create a web page form like contact form or any other form text field. if you want to allow only numeric letters like (0-9)

    <input name="number">
    
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    
    <script type="text/javascript">
    // Numeric only control handler
    jQuery.fn.ForceNumericOnly =
    function()
    {
        return this.each(function()
        {
            $(this).keydown(function(e)
            {
                var key = e.charCode || e.keyCode || 0;
                // allow backspace, tab, delete, enter, arrows, numbers and keypad numbers ONLY
                // home, end, period, and numpad decimal
                return (
                    key == 8 || 
                    key == 9 ||
                    key == 13 ||
                    key == 46 ||
                    key == 110 ||
                    key == 190 ||
                    (key >= 35 && key <= 40) ||
                    (key >= 48 && key <= 57) ||
                    (key >= 96 && key <= 105));
            });
        });
    };
    $('input[name="number"]').ForceNumericOnly();
    </script>
  • 2.9 Years

    • Category : Html
    • Location : Chandigarh
    • Posted On : Jan 21, 2016
    <form action="demo_form.asp">
    Password: <input type="password" name="pw" pattern=".{6,}" title="Six or more characters">
    <input type="submit">
    </form>

     

  • 2.9 Years

    • Category : Php
    • Location : Chandigarh
    • Posted On : Mar 16, 2016
    <?php 
    include('config.php'); //connection file
    //header to give the order to the browser
    header('Content-Type: text/csv');
    header('Content-Disposition: attachment;filename=user.csv');
    //select table to export the data
    $select_table=mysql_query('select `email` from login');
    $rows = mysql_fetch_assoc($select_table);
    
    if ($rows)
    {
    getcsv(array_keys($rows));
    }
    while($rows)
    {
    getcsv($rows);
    $rows = mysql_fetch_assoc($select_table);
    }
    
    // get total number of fields present in the database
    function getcsv($no_of_field_names)
    {
    $separate = '';
    
    
    // do the action for all field names as field name
    foreach ($no_of_field_names as $field_name)
    {
    /*if (preg_match('/\\r|\\n|,|"/', $field_name))
    {
    $field_name = '' . str_replace('', $field_name) . '';
    }*/
    echo $separate . $field_name;
    
    //sepearte with the comma
    $separate = ',';
    }
    
    //make new row and line
    echo "\r\n";
    }
    ?>

     

  • 5.11 Years

    • Category : Php
    • Location : Mohali
    • Posted On : Jan 10, 2018

    PHP you can easily do this using the mysqli_connect() function. All communication between PHP and the MySQL database server takes place through this connection. The basic syntaxes for connecting to MySQL using MySQLi and PDO extensions:

    Syntax: MySQLi, Procedural way
    $con = mysqli_connect("hostname", "username", "password", "database");
    Syntax: MySQLi, Object Oriented way
    $con = new mysqli("hostname", "username", "password", "database");
    Syntax: PHP Data Objects (PDO) way
    $pdo = new PDO("mysql:host=hostname;dbname=database", "username", "password"); 
    Example (mysqli)

    Perform queries against the database:
    <?php
    $con=mysqli_connect("localhost","your_user","your_password","your_db");
    // Check connection
    if(mysqli_connect_errno())
    {
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
    }
    
    // Perform queries
    mysqli_query($con,"SELECT * FROM yourtable");
    mysqli_query($con,"INSERT INTO yourtable (FName,LName,Age)
    VALUES ('Glen','Quagmir',65)");
    
    mysqli_close($con);
    ?> 
    Example (PDO)

    Perform queries against the database:
    <?php
    $servername = "localhost";
    $username = "your_username";
    $password = "your_password";
    $dbname = "your_DBPDO";
    
    try {
        $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
        // set the PDO error mode to exception
        $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    
        // prepare sql and bind parameters
        $stmt = $conn->prepare("INSERT INTO yourGuests (ftname, lname, email)
        VALUES (:ftname, :lname, :email)");
        $stmt->bindParam(':ftname', $firstname);
        $stmt->bindParam(':lname', $lastname);
        $stmt->bindParam(':email', $email);
    
        // insert a row
        $firstname = "John";
        $lastname = "Doe";
        $email = "john@domain.com";
        $stmt->execute();
    
        // insert another row
        $firstname = "Julie1";
        $lastname = "Dooley1";
        $email = "julie1@domain.com";
        $stmt->execute();
    
        echo "New records added successfully";
        }
    catch(PDOException $e)
    {
    echo "Error: " . $e->getMessage();
    }
    $conn = null;
    ?> 
     
  • 2.9 Years

    • Category : Jquery
    • Location : Chandigarh
    • Posted On : Jan 25, 2017

    You can change background of container using this code

    Html:
    
    <form class="form-inline">
         <div class="form-group">
          <label for="fileToUpload"> <img src="images/upload.png'; ?> " width="200" height="100" id="blah1" /></label>
           <div class="input-group">
      <input type="file" name="exmaple" id="fileToUpload"  required>
      <input type="hidden" id="backupimgurl" val="">
     </div>
      </div>
            <div class="form-group">
        <div class="input-group">
     <select class="form-control" onchange="$('#home-page').css({'background-position':$(this).val()});" name="BackgroundPosition" id="BackgroundPosition">
        <option value="center" selected="selected">Center</option>
        <option value="center top">Center/Top</option>
        <option value="center bottom">Center/Bottom</option>
        <option value="left center">Left/Center</option>
        <option value="left top">Left/Top</option>
        <option value="left bottom">Left/Bottom</option>
        <option value="right center">Right/Center</option>
        <option value="right top">Right/Top</option>
        <option value="right bottom">Right/Bottom</option>
      </select>
     </div>
     </div>
     <div class="form-group">
      <div class="input-group">
      <select class="form-control" onchange="$('#home-page').css({'background-repeat':$(this).val()});" name="BackgroundImageRepeat" id="BackgroundImageRepeat">
       <option value="repeat-x">Repeat Horizontal</option>
       <option value="repeat-y">Repeat Vertical</option>
       <option value="repeat">Repeat</option>
        <option value="no-repeat" selected="selected">No Repeating</option>
          </select>
      </div>
    </div>
    <div class="form-group">
      <div class="input-group">
       <input class="form-control" value="" name="BackgroundColor" style="width:80%; display:inline-block;" maxlength="6" placeholder="color">
     </div>
      </div>
     <div class="form-group">
     <div class="input-group">
         <button type="submit" class="btn btn-success">Save</button>
         </div>
          <div class="input-group">
         <button type="submit" class="btn btn-danger">Cancel</button>
        </div>
       </div>
    </form>
    
    jQuery:
    
    jQuery(document).on('change','#fileToUpload',function(){
     var imgbg = window.URL.createObjectURL(this.files[0]);
      jQuery('#backupimgurl').val(imgbg);
       //console.log(imgbg);
     jQuery('#home-page').css({backgroundImage: "url(" imgbg ")"});
    });
    
  • 2.9 Years

    • Category : Php
    • Location : Chandigarh
    • Posted On : Dec 23, 2015

    echo  date('Y-m-d', strtotime('-3 days'));

  • 5.11 Years

    • Category : Php
    • Location : Mohali
    • Posted On : Jul 2, 2016

    When you’re using a sophisticated design, CSS files can quickly become very long, and takes time to load. I have compiled interresting ways of compressing CSS files by using PHP.

    (1.)
    <link rel="stylesheet" type="text/css" media="screen" href="/style.css.php"/>
    Once you successfully rename your css files, edit it and add the following code at the beginning of the file:
    <?php if(extension_loaded('zlib')){ob_start('ob_gzhandler');} header("Content-type: text/css"); ?>
     

    2 Answers

    View More
  • 2.9 Years

    • Category : Php
    • Location : Chandigarh
    • Posted On : Apr 6, 2016

    When we add longtext and it include special character like (',") its stop execution of query.this code help you to resolve this problem

    $desc=mysql_real_escape_string('your text');