Handle NULL Values in MySQL Table Using PHP Script

Srinivas Gorla
Updated on 22-Jun-2020 14:09:52

403 Views

We can use the if...else condition in PHP script to prepare a query based on the NULL value. To illustrate it we are having the following example −ExampleIn this example, we are using the table named ‘tcount_tbl’ having the following data −mysql> SELECT * from tcount_tbl; +-----------------+----------------+ | tutorial_author | tutorial_count | +-----------------+----------------+ |      mahran     |       20       | |      mahnaz     |      NULL      | |       Jen       |      NULL      | |      Gill       |       20       | +-----------------+----------------+ 4 rows in set (0.00 sec)Now, the following is a PHP script that takes the value of ‘tutorial_count’ from outside and compares it with the value available in the field.

Find Smallest Element from Array Using Lambda Expressions in C#

karthikeya Boyini
Updated on 22-Jun-2020 14:09:40

560 Views

Declare an array −int[] arr = { 10, 15, 5, 20};Now to get the smallest element from an array, use Min() method with lambda expressions −arr.Min());Here is the complete code −Example Live Demousing System; using System.Linq; class Demo {    static void Main() {       int[] arr = { 10, 15, 5, 20};       Console.WriteLine(arr.Min(element => Math.Abs(element)));    } }Output5

Convert Several Strings into a Single Comma Delimited String in C#

Samual Sam
Updated on 22-Jun-2020 14:09:08

446 Views

Set the strings −List val = new List(); // list of strings val.Add("water"); val.Add("food"); val.Add("air");Use Join method to convert several strings into a single comma-delimited string −string.Join(",", val.ToArray());Here is the complete code −Example Live Demousing System; using System.Collections.Generic; public class Demo {    public static void Main() {       List val = new List();       // list of strings       val.Add("water");       val.Add("food");       val.Add("air");       string res = string.Join(",", val.ToArray());       Console.WriteLine(res);    } }Outputwater,food,air

Create MySQL Temporary Table Using PHP Script

radhakrishna
Updated on 22-Jun-2020 14:08:57

2K+ Views

As we know that PHP provides us the function named mysql_query() to create a MySQL table. Similarly, we can use mysql_query() function to create MySQL temporary table. To illustrate this, we are using the following example −ExampleIn this example, we are creating a temporary table named ‘SalesSummary’ with the help of PHP script in the following example −           Creating MySQL Temporary Tables              

Get List of Keys from a Dictionary in C#

karthikeya Boyini
Updated on 22-Jun-2020 14:08:38

6K+ Views

Set the dictionary elements −Dictionary d = new Dictionary(); // dictionary elements d.Add(1, "One"); d.Add(2, "Two"); d.Add(3, "Three"); d.Add(4, "Four"); d.Add(5, "Five"); d.Add(6, "Six"); d.Add(7, "Seven"); d.Add(8, "Eight");To get the keys, use a list collection −List keys = new List(d.Keys);Loop through the keys and display them.Here is the complete code −Example Live Demousing System; using System.Collections.Generic; public class Demo {    public static void Main() {       Dictionary d = new Dictionary();       // dictionary elements       d.Add(1, "One");       d.Add(2, "Two");       d.Add(3, "Three");       d.Add(4, "Four"); ... Read More

PHP Function to Get Number of Affected Rows by MySQL Query

Nikitha N
Updated on 22-Jun-2020 14:08:04

238 Views

PHP uses mysql_affected_rows( ) function to find out how many rows a query changed. This function basically returns the number of affected rows in the previous SELECT, INSERT, UPDATE, REPLACE, or DELETE query. Return of an integer > 0 indicates the number of rows affected, 0 indicates that no records were affected and -1 indicates that the query returned an error. Its syntax is as follows −Syntaxmysql_affected_rows( connection );Followings are the parameters used in this function −S. No.Parameter & Description1.ConnectionRequired – Specifies the MySQL connection to use

Insert Element at Second Position in a Chash List

Samual Sam
Updated on 22-Jun-2020 14:08:04

617 Views

Here is our list −List val = new List (); // list of strings val.Add("water"); val.Add("food"); val.Add("air");Use the Insert() method to insert an element in the list. With that, also set where you want to add it. We have set the new text at position 1st −val.Insert(1, "shelter");The following is the complete code −Example Live Demousing System; using System.Collections.Generic; public class Demo {    public static void Main() {       List val = new List ();       // list of strings       val.Add("water");       val.Add("food");       val.Add("air");       ... Read More

Insert Multiple Elements in a Chash List

karthikeya Boyini
Updated on 22-Jun-2020 14:07:28

3K+ Views

Use the InsertRange() method to insert a list in between the existing lists in C#. Through this, you can easily add more than one element to the existing list.Let us first set a list −List arr1 = new List(); arr1.Add(10); arr1.Add(20); arr1.Add(30); arr1.Add(40); arr1.Add(50);Now, let us set an array. The elements of this array are what we will add to the above list −int[] arr2 = new int[4]; arr2[0] = 60; arr2[1] = 70; arr2[2] = 80; arr2[3] = 90;We will add the above elements to the list −arr1.InsertRange(5, arr2);Here is the complete code −Example Live Demousing System; using System.Collections.Generic; public ... Read More

Get the Range of Elements in a Chash List

Samual Sam
Updated on 22-Jun-2020 14:06:43

3K+ Views

Use the GetRange() method to get the range of elements −Firstly, set a list and add elements −List arr1 = new List(); arr1.Add(10); arr1.Add(20); arr1.Add(30); arr1.Add(40); arr1.Add(50);Now, under a new list get the range of elements between index 1 and 3 −List myList = arr1.GetRange(1, 3);Here is the complete code −Example Live Demousing System; using System.Collections.Generic; public class Demo {    public static void Main() {       List arr1 = new List();       arr1.Add(10);       arr1.Add(20);       arr1.Add(30);       arr1.Add(40);       arr1.Add(50);       Console.WriteLine("Initial List ...");   ... Read More

Release Cursor Memory in MySQL using PHP

varun
Updated on 22-Jun-2020 14:06:01

216 Views

PHP uses mysql_free_result() function to release the cursor memory associated with MySQL result. It returns no value.SyntaxMysql_free_result(result);Followings are the parameters used in this function −Sr.NoParameter & Description1ResultRequired- Specifies a result set identifier returned by mysql_query(), mysql_store_result() or mysql_use_result()

Advertisements