Sensation Energy


Function 7 - MASTER

Documentation

Introduction

Function 7 - MASTER is a multi-purpose crud that is suitable for developing multi-purpose applications. Consists of:

  • Add
      1. Single
        Multi
  • Export
      1. Print all (PDF)
        Print single
        Copy to Clipboard
        Excel
        CSV
  • Search
      1. Search by (Id, Firts Name, Last Name, Eamil, Date)
        Search by key word
        Search by date (From date - to date)
  • Check
      1. Hide columns (Firts Name, Last Name, Eamil, Date)
        Multi crud (multi view, edit or delete)
        Search by date (From date - to date)

Content (conn.php)


<?php
$server = "localhost";
$user = "root";
$password = "root";
$base = "fun_7";
$con = mysqli_connect($server, $user, $password, $base);
?>

Database


CREATE TABLE `users` (
`user_id` int(20) NOT NULL,
`first_name` varchar(100) NOT NULL,
`last_name` varchar(100) NOT NULL,
`email` varchar(100) NOT NULL,
`image` text NOT NULL,
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
ALTER TABLE `users`
ADD PRIMARY KEY (`user_id`);
ALTER TABLE `users`
MODIFY `user_id` int(20) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=102;

Add, Add multi

Add

Form with function for insert value in database (porcedural php)

Form


<form method="POST" action="function.php" enctype="multipart/form-data">
<input type="hidden" name="size" value="1000000">
<div class="form-group">
<label for="image">Image</label>
<input type="file" name="image" class="form-input">
</div>
<div class="form-group">
<label>First Name:</label>
<input type="text" name="first_name" placeholder="First Name"  class="form-input" />
</div>
<br>
<div class="form-group">
<label>Last Name</label>
<input type="text" name="last_name" class="form-input">
</div>
<div class="form-group">
<label for="datum">Date</label>
<input type="date" name="date" class="form-input">
</div>
<div class="form-group">
<label>Email:</label>
<input type="text" name="email" class="form-input">
</div>
<br>
<div class="btn-group">
<button type="submit" name="add">Add</button>
</form>

Function


<?php
require_once "conn.php";
if (isset($_POST['add'])) {
$image = $_FILES['image']['name'];
$target = "../images/".basename($image);
$first_name = $_POST['first_name'];
$last_name = $_POST['last_namee'];
$email = $_POST['email'];
$date = $_POST['date'];
$sql = "INSERT INTO users (first_name, last_name, email, date, image) VALUES('$first_name','$last_name', '$email','$date', '$image')";
mysqli_query($con, $sql);
if (move_uploaded_file($_FILES['image']['tmp_name'], $target)) {
echo "<script>window.history.go(-2);</script>";
}else{
echo  "Error";
}
}
?>

Add multi

Form with function for insert multiple value in database. This means that you can select multiple names from the database and insert them with other values into the database.

Form


<form method="POST" action="function.php" enctype="multipart/form-data">
 <input type="hidden" name="size" value="1000000">
 <div class="form-group">
 <label>Image</label>
 <input type="file" name="image" class="form-input">
 </div>
 <br>
 <div class="form-group">
 <div align="center">
 <input type="checkbox" onClick="toggle(this)" /> Toggle All<br><br>
 </div>
 <?php
 $sql = "SELECT first_name FROM users";
 $res = mysqli_query($con,$sql);
 while( $row = mysqli_fetch_assoc($res) )
 {
 $first_name= $row['first_name'];
 $first_name_list = $first_name;
 $total_first_name = (is_array($first_name_list) && count($ime_list));
 for ($counter=0; $counter<$total_ime; $counter++) {
 $first_name_list[$counter] = trim($first_name_list[$counter]);
 }
 $first_name_list = $first_name_list;
 echo $first_name_list ;
 ?>
 <input name="bookmark[]" type="checkbox" value="<?php echo $first_name_list[$counter] = trim($first_name_list[$counter]);; ?>">
 <?php 	} ?>
 <br>
 </div>
 <div class="form-group">
 <label>Last name</label>
 <input type="text" name="last_name" class="form-input">
 </div>
 <div>
 <label>Date</label>
 <input type="date" name="date" class="form-input">
 </div>
 <div class="form-group">
 <label>Email:</label>
 <input type="text" name="email" class="form-input">
 </div>
 <div class="btn-group">
 <button type="submit" name="add" >Add/button>
 </div>
 </form>

Function


<?php
require_once "conn.php";
if (isset($_POST['add'])) {
$sql = "SELECT first_name FROM users";
$res = mysqli_query($con,$sql);
while( $row = mysqli_fetch_assoc($res) )
{
$first_name = $row['first_name'];
$first_name_list = $first_name;
}
$image = $_FILES['image']['name'];
$target = "../images/".basename($image);
$first_name= $_POST['first_name'];
$last_name = $_POST['last_name'];
$email = $_POST['email'];
$date = $_POST['date'];
$first_name=$_POST['bookmark'];
$N = count($ime);
for($i=0; $i < $N; $i++)
{
$sql = "INSERT INTO users (first_name, last_name, email, date, image) VALUES('$first_name[$i]','$last_name', '$email','$date', '$image')";
mysqli_query($con, $sql);
}
if (move_uploaded_file($_FILES['image']['tmp_name'], $target)) {
echo "<script>window.history.go(-2);</script>";
}else{
echo  "Error";
}
}
?>

Print, Copy, Export




Check




Multi CRUD




CRUD




Content


Documentation


Answer the following question:

You must be logged in


Advertising