Posts

Showing posts from May, 2017

photo upload

<html> <head>  <script src="assets/js/jquery-1.10.2.js"></script>     <!-- BOOTSTRAP SCRIPTS -->     <script src="assets/js/bootstrap.js"></script>     <!-- PAGE LEVEL SCRIPTS -->     <script src="assets/js/bootstrap-fileupload.js"></script>     <!-- METISMENU SCRIPTS -->     <script src="assets/js/jquery.metisMenu.js"></script>     <!-- CUSTOM SCRIPTS -->     <script src="assets/js/custom.js"></script>         </head> <body> <form method="post" enctype="multipart/form-data"> <input  type="file" name="photo"><br> <input type="submit" name="submit" value="SEND"> </form>     <?php         $con=mysqli_connect("localhost","root","root","img") or die(mysqli_error()); if(isset($_POST['submit

view record

<!DOCTYPE html> <html> <head>     <title></title> </head> <body> <?php      $dbname="demo";     $con=mysqli_connect("localhost","root","root","demo") or die(mysqli_error());    $query=mysqli_query($con,"select * from tbl1 ") or die(mysqli_error($con));    ?>    <table border="1">            <tr>                <td>Name</td>                <td>surname</td>            </tr>      <?php      while($row=mysqli_fetch_array($query))      {      extract($row);      ?>      <tr>          <td><?php echo $row['name']; ?></td>          <td><?php echo $row['surname']; ?></td>      </tr> <?php } ?>    </table> </body> </html>

Assignment

Image

How to insert data into Database using PHP

 1. Create Form and give name form.php, the file look like :            <form method="post" action="insert.php">              <label>Name</label>              <input type="text" name="name" />                          <label>Surname</label>              <input type="text" name="surname" />             <input type="submit" name="submit" />          </form>  2. create database connection and give name db.php and create table give name tbl1, the file look like :       <?php             $con=mysqli_connect("localhost","root","root","demo") or     die(mysqli_error()); 3. create insert.php file , the file look like :          <?php          include "db.php"; if(isset($_POST['submit']))     {            extract($_POST);     $query=mysqli_query($con,"insert into tbl1

How to connect to database using PHP and MySQL

<?php $dbname="your db name"; $server="your server name e.g. localhost"; $username="your username e.g. root"; $password=" your password"; $connect = mysqli_connect($dbname,$server,$username,$password) or die(mysqli_error()); if($connect) {  echo "Database connection successfully.."; }else { echo "error while connecting  to the database"; } ?>