Posts

Recent Post

Writing data to a file using Python

  Writing data to a file using Python Writing data to a file in Python can be done in a variety of ways, depending on the file type and how you want to save the data. Here's a general guide to common formats. 1. Writing Text to a Plain Text File # Writing text data data = "This is some text data." # Open a file in write mode ('w') and write data with open("output.txt", "w") as file:     file.write(data) 2. Writing Data to a CSV File import csv # Data to write data = [     ["Name", "Age", "City"],     ["Rajesh", 25, "India"],     ["Shaun", 30, "San Francisco"],     ["Afzal", 35, "Chicago"] ] # Writing to a CSV file with open("output.csv", "w", newline="") as file:     writer = csv.writer(file)     writer.writerows(data) 3. Writing Data to a JSON File import json # Data to write data = {     "Name": "Alice", ...

Insert Records to the database Using PHP and MySQL

  To add records to the MySQL table the INSERT statement is used  To add any new records to the table we use INSERT query, which is very simple to understand and work with. Syntax: INSERT INTO Table_name (Column1, Column2, Column3, Column4... Column N) VALUES (Value1, Value2, Value3, Value4... Value N) Example: INSERT INTO mydata_tbl (Name, Gender, Age, Education) VALUES ('ABCD', 'F', 25, 'MSc') Here, in the example mydata_tbl is the name of the given table. Name, Age, Gender,  and Education are the Columns and their values are ABCD, F,25, and MSc respectively.                                                                               Other Essential MySQL Commands SELECT - To choose specific data ( record ) from  your Database   UPD...

Update and Delete Record Using PHP and MySQL

Update and Delete Record Using PHP and MySQL UPDATE  Query :  To Update data in your Database Syntax: UPDATE Table_name SET column=value WHERE other_column = other_value DELETE Query To delete the record from your Database To delete the data frothe m database you should use the DELETE query, the syntax is given below: DELETE  FROM Table_name WHERE column = value                                                                                                                                                      HAPPY CODING😍

PHP Login Page With Database Connection

Image
  In order to create a login page using php and html, several steps must be taken. Step 1: First we need to create database_connection.php page database_connection.php <?php     $Server_name="localhost";     $Username="root";      $Password="";     $ Database="details_db";      $link=mysqli_connect($Server_name,$Username,$Password,$Database); ?> Step 2: Make a table called details_db,and create a tale called admin_tbl. The table has four columns:admin_id,username,password,and created_date(its an optional). Step 3: Login_page.html <html>     <head>          <title>PHP LOGIN PAGE WITH DATABASE CONNECTION<title>      </head>      <body>          <center>ADMIN LOGIN <br><br>          <form action="Login_process.php" method="POST">    ...

Working with CSV file Using Python

Image
About CSV Comma-separated values are known as CSV. It is the simplest form of storing data in tabular form as plain text. Data Scientists need to know how to work with CSV data because most of their activities involve CSV data.In CSV files, the first line contains the field/feature names. The following lines of the file are observations/records. The values of a record are separated by “comma.” Here we have a file named “annual-energy-survey-demo-csv.csv” using this CSV file, we will try to learn how to  read and write the CSV files. In this article, I'll explain in detail how you can read and write CSV files in Python.   # Import the csv library import csv # Open the CSV file file = open ( '/content/drive/MyDrive/annual-enpr-survey-demo-csv.csv' ) type ( file ) output: io.TextIOWrapper # Use the csv.reader object to read the CSV file  csvreader = csv.reader( file ) # Extract the fields names csv_header = [] csv_header = next (csvreader) print(header)   Output:...

Validation Code For Phone Number Using preg_match() in Php

Image
Phone Number Validation Using preg_match() Below code shows validation of Phone Number 1)Checking whether user input (Phone Number) contains an alphabet in Phone Number          <?php         $mobile_no="123fdgdg890";        if(preg_match("/[a-z][A-Z]/i", $mobile_no))        {   echo "Invalid Phone Number!";        }else{                echo "Valid Phone Number!";        }      ?> Output :Invalid Phone Number! Syntax preg_match("/[a-z][A-Z]/i", $mobile_no) The above syntax will verify whether given phone number is well-formed or not.if it is not, it will show an error message. The    preg_match()  function helps to find whether a given variable is valid or not. 2 )Checking whether user input (Phone Number) contains 10 digits in Phone Number      <?php...

Simple HTML Form Elements For Registration Page Example

Image
<!DOCTYPE html> <html lang="en">     <head>         <title>Form Elements</title>         <link href="bootstrap.min.css" rel="stylesheet" type="text/css"  />         <style type="text/css">             .Mycontainer{                 margin-left: 30px;                 margin-right: 50px;                 margin-top: 10px;             }             .mb10{                 margin-bottom: 10px;             }         </style>     </head>     <body>         <div class="Mycontainer">             ...