Write PHP Script Using MySQL JOINS to Join Two Tables

mkotla
Updated on 22-Jun-2020 14:11:18

5K+ Views

We can use the syntax of MySQL JOIN for joining two tables into the PHP function – mysql_query(). This function is used to execute the SQL command and later another PHP function – mysql_fetch_array() can be used to fetch all the selected data.To illustrate it we are having the following example −ExampleIn this example, we are using two MySQL tables which have the following data −mysql> SELECT * FROM tcount_tbl; +-----------------+----------------+ | tutorial_author | tutorial_count | +-----------------+----------------+ | mahran          |      20        | | mahnaz          |     ... Read More

Chash Ticksper Constants

Ankith Reddy
Updated on 22-Jun-2020 14:11:18

258 Views

TicksPer constants in C# have TicksPerDay, TicksPerHour, TicksPerMinute, TicksPerSecond, and TicksPerMillisecond constants. A millisecond consists of 10,000 ticks.Here are the TicksPer constants −TimeSpan.TicksPerDay TimeSpan.TicksPerHour TimeSpan.TicksPerMinuteExample Live Demousing System; using System.Linq; public class Demo {    public static void Main() {       // TicksPer constant       Console.WriteLine(TimeSpan.TicksPerDay);       Console.WriteLine(TimeSpan.TicksPerHour);       Console.WriteLine(TimeSpan.TicksPerMinute);    } }Output864000000000 36000000000 600000000

Exact Representation of No Time in Chash

Arjun Thakur
Updated on 22-Jun-2020 14:10:56

106 Views

Use the TimeSpan.Zero to represent the exact representation of no time i.e −00:00:00Set an object for TimeSpan −TimeSpan ts;Now, the TimeSpan.Zero is used to display no time −TimeSpan ts = TimeSpan.Zero;Example Live Demousing System; using System.Linq; public class Demo {    public static void Main() {       TimeSpan ts = TimeSpan.Zero;       Console.WriteLine(ts);    } }Output00:00:00

Format Timespan in C#

Chandu yadav
Updated on 22-Jun-2020 14:10:36

3K+ Views

You can format a TimeSpan in the hh: mm: ss format in C#.Firstly, set the TimeSpan −TimeSpan ts = new TimeSpan(9, 15, 30);To format TimeSpan −{0:hh\:mm\:ss}The following is the code −Example Live Demousing System; using System.Linq; public class Demo {    public static void Main() {       TimeSpan ts = new TimeSpan(9, 15, 30);       Console.WriteLine("{0:hh\:mm\:ss}", ts);    } }Output09:15:30

C# Program to Find the Index of an Element in a List

karthikeya Boyini
Updated on 22-Jun-2020 14:10:03

1K+ Views

Set a list and add elements −List val = new List(); // integer elements val.Add(35); val.Add(55); val.Add(68);Let’s say now we need to find the index of element 68. For that, use the IndexOf() method −int index = val.IndexOf(68);Here is the complete code −Example Live Demousing System; using System.Collections.Generic; public class Demo {    public static void Main() {       List val = new List();       // integer elements       val.Add(35);       val.Add(55);       val.Add(68);       // finding the index of element 68       int index = val.IndexOf(68);       Console.WriteLine(index);    } }Output2

Handle NULL Values in MySQL Table Using PHP Script

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

418 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

571 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

459 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

Advertisements