MYSQLi Tutorial for Beginners – how to create MySQLi connection with php in simple and easy steps starting from basic to advanced level. To create connection 4 parameter is required : “hostname” , “username“, “password” and “database name” see below..how…
Expand +Tag: How To
How to write connection class to mysql database using php
Hello! In this post, you will learn to how to write and test the OOP based connection class to mysql database using php. see below..how to do it.. connection.php
|
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
<?php /** @author tutorialswebsite *@ copyright 2016 */ class createDBConnection // create a class for make connection { var $host="localhost"; var $username="username"; var $password="password"; var $database="database name"; var $dbconn; function connectToDatabase() //specify the server details for mysql { $conn=mysql_connect($this->host,$this->username,$this->password); if(!$conn)//testing the connection { die("Cannot connect to the database"); }else{ $this->dbconn=$conn; echo "Connection established"; } return $this->dbconn; } function selectDatabase() // selecting the database { //use php inbuild function foer select database mysql_select_db($this->database); if(mysql_error()) // if error occured display the error message { echo "Cannot find the database".$this->database; } echo "Database Selected.."; } function closeConnection() // close the connection { mysql_close($this->dbconn); echo "Connection closed"; } } ?> |
Now you have create the database connection class let’s see…
Expand +How to show image thumbnail before upload with jQuery
Now, i am going to Share: How to show image thumbnail before upload with jQuery Step 1:- Put the following code in <body></body> section.
|
2 3 4 5 |
<div id="previewimg"></div> <input id="upload_file" class="img" name="image" type="file" /> |
Step 2:- Put the script code in <head></head> section.
|
2 3 4 5 6 7 |
<script src="http://code.jquery.com/jquery-1.10.2.js"></script> <script type="text/javascript">// <![CDATA[ $(function() { $("#upload_file").on("change", function() { var files = !!this.files ? this.files : []; if (!files.length || !window.FileReader) return; // no file selected, or no FileReader support if (/^image/.test( files[0].type)){ // only image file var reader = new FileReader(); // instance of the FileReader reader.readAsDataURL(files[0]); // read the local file reader.onloadend = function(){ // set image data as background of div $("#previewimg").css("background-image", "url("+this.result+")"); } } }); }); // ]]></script> |
Step 3:- Put following CSS…
Expand +How to integrate Gravity Forms with Google Spreadsheets:
Gravity Forms is an extremely popular Forms plugin for the WordPress. When someone submits a form created with Gravity Forms, the form data is saved inside the MySQL database . There are step by step process to integrate Gravity Forms with…
Expand +How to create pagination using PHP and MYSQL
Paging (Pagination) means showing Database results in multiple pages instead of one long page. if we have more than 100 records in database and we want to show all results but not in a single page, so we can devide…
Expand +How to create line chart in php and my sql
Line chart graph is very usefull to show sell and purchase graph layout of monthly, weekly, yearly as we want. To create line graph: first ,we create a index.php file to show garph and second, create get_line_chart.php to  get data…
Expand +How to create first HTML Page
step-1: First, Open your text editor and create a new text file, then type something like this:
|
2 3 4 5 6 7 8 9 10 11 12 13 |
<!DOCTYPE html> <html> <head> <title>Hi there</title> </head> <body> This is a page a simple page </body> </html> |
Step-2: After this save the page like: my_page.html Step-3: find the file you just created and open it with your browser (double-click,…
Expand +