diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..3f8c636 Binary files /dev/null and b/.DS_Store differ diff --git a/Code/.DS_Store b/Code/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/Code/.DS_Store differ diff --git a/Code/PHP MySQL - ALTER TABLE -1.php b/Code/PHP MySQL - ALTER TABLE -1.php deleted file mode 100644 index c47074f..0000000 --- a/Code/PHP MySQL - ALTER TABLE -1.php +++ /dev/null @@ -1,23 +0,0 @@ - \ No newline at end of file diff --git a/Code/PHP MySQL - ALTER TABLE -2.php b/Code/PHP MySQL - ALTER TABLE -2.php deleted file mode 100644 index 10c7f3e..0000000 --- a/Code/PHP MySQL - ALTER TABLE -2.php +++ /dev/null @@ -1,23 +0,0 @@ - \ No newline at end of file diff --git a/Code/PHP MySQL - ALTER TABLE -3.php b/Code/PHP MySQL - ALTER TABLE -3.php deleted file mode 100644 index 5a801a0..0000000 --- a/Code/PHP MySQL - ALTER TABLE -3.php +++ /dev/null @@ -1,23 +0,0 @@ - \ No newline at end of file diff --git a/Code/PHP MySQL - AND - OR and NOT Operators.php b/Code/PHP MySQL - AND - OR and NOT Operators.php new file mode 100644 index 0000000..40da0a5 --- /dev/null +++ b/Code/PHP MySQL - AND - OR and NOT Operators.php @@ -0,0 +1,46 @@ +mySQL - AND operator'; +$result = mysqli_query($con, "SELECT * from student WHERE course = 'mba' AND location='vellore'"); +while ($row = mysqli_fetch_array($result, MYSQLI_NUM)) { + printf('%s - %s - %s - %s - %s - %s - %s ', $row[0], $row[1], $row[2], $row[3], $row[4], $row[5], $row[6], $row[7]); + printf('
'); +} + +print '
'; + +//OR OPERATOR -------------------------------------- + +echo '

mySQL - OR operator

'; +$result = mysqli_query($con, "SELECT * from student WHERE course = 'PHD' OR location='OHIO' OR age='30'"); +while ($row = mysqli_fetch_array($result, MYSQLI_NUM)) { + printf('%s - %s - %s - %s - %s - %s - %s ', $row[0], $row[1], $row[2], $row[3], $row[4], $row[5], $row[6], $row[7]); + printf('
'); +} + +print '
'; + +//NOT OPERATOR -------------------------------------- +echo '

mySQL - NOT operator

'; +$result = mysqli_query($con, "SELECT * from student WHERE NOT course = 'mba' AND location='vellore'"); +while ($row = mysqli_fetch_array($result, MYSQLI_NUM)) { + printf('%s - %s - %s - %s - %s - %s - %s ', $row[0], $row[1], $row[2], $row[3], $row[4], $row[5], $row[6], $row[7]); + printf('
'); +} +print '
'; +//TWO NOT OPERATOR -------------------------------------- +echo '

mySQL - NOT operator - TWO TIMES

'; +$result = mysqli_query($con, "SELECT * from student WHERE NOT course = 'mba' AND NOT location='vellore'"); +while ($row = mysqli_fetch_array($result, MYSQLI_NUM)) { + printf('%s - %s - %s - %s - %s - %s - %s ', $row[0], $row[1], $row[2], $row[3], $row[4], $row[5], $row[6], $row[7]); + printf('
'); +} +mysqli_close($conn); diff --git a/Code/PHP MySQL - BETWEEN FUNCTION.php b/Code/PHP MySQL - BETWEEN FUNCTION.php new file mode 100644 index 0000000..fd42070 --- /dev/null +++ b/Code/PHP MySQL - BETWEEN FUNCTION.php @@ -0,0 +1,61 @@ +mySQL - BETWEEN Function '; +$result = mysqli_query($con, 'SELECT RegNo, AGE from student WHERE AGE BETWEEN 20 AND 30'); +while ($row = mysqli_fetch_array($result, MYSQLI_NUM)) { + printf('%s ---- %s', $row[0], $row[1]); + echo '
'; +} + +print '
'; + +//NOT BETWEEN Function -------------------------------------- +echo '

mySQL - NOT BETWEEN Function

'; +$result = mysqli_query($con, 'SELECT RegNo, AGE from student WHERE AGE NOT BETWEEN 20 AND 30'); +while ($row = mysqli_fetch_array($result, MYSQLI_NUM)) { + printf('%s ---- %s', $row[0], $row[1]); + echo '
'; +} + +print '
'; + +// BETWEEN - TEXT VALUE Function -------------------------------------- +echo '

mySQL - BETWEEN - TEXT VALUE Function

'; +$result = mysqli_query($con, "SELECT RegNo, FIRSTNAME from student WHERE FIRSTNAME BETWEEN 'A' AND 'D'"); +while ($row = mysqli_fetch_array($result, MYSQLI_NUM)) { + printf('%s ---- %s', $row[0], $row[1]); + echo '
'; +} + +print '
'; + +//NOT BETWEEN - TEXT VALUE Function -------------------------------------- +echo '

mySQL - NOT BETWEEN Function

'; +$result = mysqli_query($con, "SELECT RegNo, FIRSTNAME from student WHERE FIRSTNAME NOT BETWEEN 'A' AND 'P'"); +while ($row = mysqli_fetch_array($result, MYSQLI_NUM)) { + printf('%s ---- %s', $row[0], $row[1]); + echo '
'; +} + +print '
'; + +//BETWEEN - DATE Function -------------------------------------- +echo '

mySQL - DATE BETWEEN Function

'; +$result = mysqli_query($con, "SELECT RegNo, FIRSTNAME from student WHERE FIRSTNAME BETWEEN '2020-01-01' AND '2021-03-31' "); +while ($row = mysqli_fetch_array($result, MYSQLI_NUM)) { + printf('%s ---- %s', $row[0], $row[1]); + echo '
'; +} + +print '
'; + +mysqli_close($con); +?> \ No newline at end of file diff --git a/Code/PHP MySQL - BETWEEN WITH IN FUNCTION.php b/Code/PHP MySQL - BETWEEN WITH IN FUNCTION.php new file mode 100644 index 0000000..42101bd --- /dev/null +++ b/Code/PHP MySQL - BETWEEN WITH IN FUNCTION.php @@ -0,0 +1,43 @@ +mySQL - BETWEEN with IN Function '; +$result = mysqli_query($con, "SELECT RegNo, AGE from student WHERE AGE BETWEEN 20 AND 30 AND COURSE IN ('MBA')"); +while ($row = mysqli_fetch_array($result, MYSQLI_NUM)) { + printf('%s ---- %s', $row[0], $row[1]); + echo '
'; +} + +print '
'; + +//BETWEEN with NOT IN Function -------------------------------------- +echo '

mySQL - BETWEEN with NOT IN Function

'; +$result = mysqli_query($con, "SELECT RegNo, AGE from student WHERE AGE BETWEEN 20 AND 30 AND COURSE NOT IN ('MBA')"); +while ($row = mysqli_fetch_array($result, MYSQLI_NUM)) { + printf('%s ---- %s', $row[0], $row[1]); + echo '
'; +} + +print '
'; + + +//BETWEEN with NOT IN Function - OR OPERATOR -------------------------------------- +echo '

mySQL - BETWEEN with NOT IN Function - OR OPERATOR

'; + +$result = mysqli_query($con, "SELECT COURSE, AGE from student WHERE AGE BETWEEN 20 AND 30 OR COURSE NOT IN ('MBA')"); + +while ($row = mysqli_fetch_array($result, MYSQLI_NUM)) { + printf('%s ---- %s', $row[0], $row[1]); + echo '
'; +} + +mysqli_close($con); +?> \ No newline at end of file diff --git a/Code/PHP MySQL - BETWEEN.php b/Code/PHP MySQL - BETWEEN.php deleted file mode 100644 index a7b1f4c..0000000 --- a/Code/PHP MySQL - BETWEEN.php +++ /dev/null @@ -1,60 +0,0 @@ - BETWEEN "; - -$sql = "SELECT firstname FROM MyGuests WHERE ID BETWEEN 10 AND 100"; -$result = mysqli_query($conn, $sql); - -if (mysqli_num_rows($result) > 0) { - // output data of each row - while($row = mysqli_fetch_assoc($result)) { - echo "Name : " . $row["firstname"]."
"; - } -} else { - echo "0 results"; -} - -echo "
"; - -$sql = "SELECT id,firstname FROM MyGuests WHERE ID BETWEEN 10 AND 100"; -$result = mysqli_query($conn, $sql); - -if (mysqli_num_rows($result) > 0) { - // output data of each row - while($row = mysqli_fetch_assoc($result)) { - echo "id : " . $row["id"]. " - Name : " . $row["firstname"]."
"; - } -} else { - echo "0 results"; -} - -echo "
"; -echo "

NOT BETWEEN

"; - -$sql = "SELECT id,firstname FROM MyGuests WHERE ID NOT BETWEEN 10 AND 100"; -$result = mysqli_query($conn, $sql); - -if (mysqli_num_rows($result) > 0) { - // output data of each row - while($row = mysqli_fetch_assoc($result)) { - echo "id : " . $row["id"]. " - Name : " . $row["firstname"]."
"; - } -} else { - echo "0 results"; -} - - - - -mysqli_close($conn); -?> \ No newline at end of file diff --git a/Code/PHP MySQL - CREATE DATABASE CONNECTION.php b/Code/PHP MySQL - CREATE DATABASE CONNECTION.php new file mode 100644 index 0000000..83d2355 --- /dev/null +++ b/Code/PHP MySQL - CREATE DATABASE CONNECTION.php @@ -0,0 +1,8 @@ + \ No newline at end of file diff --git a/Code/PHP MySQL - CREATE DATABASE.php b/Code/PHP MySQL - CREATE DATABASE.php index acd8abe..9f36a70 100644 --- a/Code/PHP MySQL - CREATE DATABASE.php +++ b/Code/PHP MySQL - CREATE DATABASE.php @@ -1,21 +1,13 @@ - "; +} + +//Database Selection + +//mysqli_select_db($con, "myDBdd"); +if (mysqli_select_db($con, "myDB")) { + echo "Database Selected Successfully
"; +} else { + echo "Error in Selecting the Database
", mysqli_errno($con); +} + +//Table Creation + +$sql = "create table student (FirstName varchar(25), LastName varchar(25), Age varchar(3))"; + +if (!mysqli_query($con, $sql)) { + die('Error: ' . mysqli_errno($con)); +} +echo "Table Created Successfully"; + +mysqli_close($con); +?> diff --git a/Code/PHP MySQL - CREATE TABLE - 2 - PRIMARY KEY AND NOT NULL.php b/Code/PHP MySQL - CREATE TABLE - 2 - PRIMARY KEY AND NOT NULL.php new file mode 100644 index 0000000..9280d90 --- /dev/null +++ b/Code/PHP MySQL - CREATE TABLE - 2 - PRIMARY KEY AND NOT NULL.php @@ -0,0 +1,35 @@ +'; +} + +//Database Selection + +//mysqli_select_db( $con, 'myDBdd' ); +if (mysqli_select_db($con, 'myDB')) { + echo 'Database Selected Successfully
'; +} else { + echo 'Error in Selecting the Database
', mysqli_errno($con); +} + +//Table Creation + +$sql = "create table student ( + RegNo varchar(25) NOT NULL, + FirstName varchar(25), + LastName varchar(25), + Age varchar(3), + PRIMARY KEY (RegNo) + )"; + +if (!mysqli_query($con, $sql)) { + die('Error: ' . mysqli_errno($con)); +} +echo 'Table Created Successfully'; + +mysqli_close($con); +?> diff --git a/Code/PHP MySQL - CREATE TABLE - 2 - Timestamp.php b/Code/PHP MySQL - CREATE TABLE - 2 - Timestamp.php new file mode 100644 index 0000000..7e562d5 --- /dev/null +++ b/Code/PHP MySQL - CREATE TABLE - 2 - Timestamp.php @@ -0,0 +1,29 @@ +"; +} + +//Database Selection + +//mysqli_select_db($con, "myDBdd"); +if (mysqli_select_db($con, "myDB")) { + echo "Database Selected Successfully
"; +} else { + echo "Error in Selecting the Database
", mysqli_errno($con); +} + +//Table Creation + +$sql = "create table student (FirstName varchar(25), LastName varchar(25), Age varchar(3), DateofReg TIMESTAMP)"; + +if (!mysqli_query($con, $sql)) { + die('Error: ' . mysqli_errno($con)); +} +echo "Table Created Successfully"; + +mysqli_close($con); +?> diff --git a/Code/PHP MySQL - CREATE TABLE with More Fields.php b/Code/PHP MySQL - CREATE TABLE with More Fields.php new file mode 100644 index 0000000..9dc430a --- /dev/null +++ b/Code/PHP MySQL - CREATE TABLE with More Fields.php @@ -0,0 +1,29 @@ +"; +} + +//Database Selection + +//mysqli_select_db($con, "myDBdd"); +if (mysqli_select_db($con, "myDB")) { + echo "Database Selected Successfully
"; +} else { + echo "Error in Selecting the Database
", mysqli_errno($con); +} + +//Table Creation + +$sql = "create table student (RegNo varchar(10), FirstName varchar(25), LastName varchar(25), Age Int(3), Email varchar(25), Location Varchar(25), Course varchar(10))"; + +if (!mysqli_query($con, $sql)) { + die('Error: ' . mysqli_error($con)); +} +echo "Table Created Successfully"; + +mysqli_close($con); +?> diff --git a/Code/PHP MySQL - CREATE TABLE.php b/Code/PHP MySQL - CREATE TABLE.php deleted file mode 100644 index fda795e..0000000 --- a/Code/PHP MySQL - CREATE TABLE.php +++ /dev/null @@ -1,30 +0,0 @@ - \ No newline at end of file diff --git a/Code/PHP MySQL - Create DB Connection.php b/Code/PHP MySQL - Create DB Connection.php deleted file mode 100644 index 96a814f..0000000 --- a/Code/PHP MySQL - Create DB Connection.php +++ /dev/null @@ -1,9 +0,0 @@ - \ No newline at end of file diff --git a/Code/PHP MySQL - DELETE.php b/Code/PHP MySQL - DELETE.php deleted file mode 100644 index 19f09ec..0000000 --- a/Code/PHP MySQL - DELETE.php +++ /dev/null @@ -1,23 +0,0 @@ - \ No newline at end of file diff --git a/Code/PHP MySQL - DROP DATABASE.php b/Code/PHP MySQL - DROP DATABASE.php new file mode 100644 index 0000000..3e1aa5a --- /dev/null +++ b/Code/PHP MySQL - DROP DATABASE.php @@ -0,0 +1,13 @@ + diff --git a/Code/PHP MySQL - Display Output in Table Format.php b/Code/PHP MySQL - Display Output in Table Format.php new file mode 100644 index 0000000..c854a6a --- /dev/null +++ b/Code/PHP MySQL - Display Output in Table Format.php @@ -0,0 +1,34 @@ + + + + + RegNo + FirstName + LastName + Course + Location + '; + +if ($result = mysqli_query($con, $query)) { + while ($row = mysqli_fetch_assoc($result)) { + $field1name = $row["RegNo"]; + $field2name = $row["FirstName"]; + $field3name = $row["LastName"]; + $field4name = $row["Course"]; + $field5name = $row["Location"]; + + echo ' + '.$field1name.' + '.$field2name.' + '.$field3name.' + '.$field4name.' + '.$field5name.' + '; + } +} +?> + + \ No newline at end of file diff --git a/Code/PHP MySQL - IN FUNCTION.php b/Code/PHP MySQL - IN FUNCTION.php new file mode 100644 index 0000000..99bd0d9 --- /dev/null +++ b/Code/PHP MySQL - IN FUNCTION.php @@ -0,0 +1,33 @@ +mySQL - IN Function '; +$result = mysqli_query($con, "SELECT RegNo, FirstName, Course from student WHERE COURSE IN ('BTECH','MCA')"); + +while ($row = mysqli_fetch_array($result, MYSQLI_NUM)) { + printf('%s -- %s -- %s', $row[0], $row[1], $row[2]); + echo '
'; +} + +print '
'; + +//NOT IN Function -------------------------------------- +echo '

mySQL - NOT IN Function

'; +$result = mysqli_query($con, "SELECT RegNo, FirstName, Course from student WHERE COURSE NOT IN ('BTECH','MCA', 'BCA','BSC','MS','MBA')"); + +while ($row = mysqli_fetch_array($result, MYSQLI_NUM)) { + printf('%s -- %s -- %s', $row[0], $row[1], $row[2]); + echo '
'; +} + +print '
'; + +mysqli_close($con); +?> \ No newline at end of file diff --git a/Code/PHP MySQL - INSERT INTO TABLE - 1.php b/Code/PHP MySQL - INSERT INTO TABLE - 1.php new file mode 100644 index 0000000..85c7ea5 --- /dev/null +++ b/Code/PHP MySQL - INSERT INTO TABLE - 1.php @@ -0,0 +1,16 @@ +" . mysqli_error($conn); +} +mysqli_close($conn); +?> \ No newline at end of file diff --git a/Code/PHP MySQL - INSERT INTO TABLE - 2 - Timestamp.php b/Code/PHP MySQL - INSERT INTO TABLE - 2 - Timestamp.php new file mode 100644 index 0000000..0b90769 --- /dev/null +++ b/Code/PHP MySQL - INSERT INTO TABLE - 2 - Timestamp.php @@ -0,0 +1,17 @@ +" . mysqli_error($conn); +} +mysqli_close($conn); +?> \ No newline at end of file diff --git a/Code/PHP MySQL - INSERT INTO TABLE via FORM.php b/Code/PHP MySQL - INSERT INTO TABLE via FORM.php index fb1b256..e8f8b8e 100644 --- a/Code/PHP MySQL - INSERT INTO TABLE via FORM.php +++ b/Code/PHP MySQL - INSERT INTO TABLE via FORM.php @@ -2,10 +2,11 @@ -
+ firstname: - lastname: - Age: +
lastname: +
Age: +
@@ -14,16 +15,15 @@ // INSERT INTO TABLE PHP \ No newline at end of file +$con = mysqli_connect("localhost", "root", "root", "myDB"); +if (!$con) { + die("Connection failed: " . mysqli_connect_error($con)); +} +//Inserting to Database via HTML Table +$sql = "INSERT INTO student (FirstName, LastName, Age) VALUES ('$_POST[firstname]','$_POST[lastname]','$_POST[age]')"; +if (!mysqli_query($con, $sql)) { + die('Error: ' . mysqli_error($con)); +} +echo "1 record added"; +mysqli_close($con); +?> \ No newline at end of file diff --git a/Code/PHP MySQL - INSERT INTO TABLE with More Fields.php b/Code/PHP MySQL - INSERT INTO TABLE with More Fields.php new file mode 100644 index 0000000..470ea2b --- /dev/null +++ b/Code/PHP MySQL - INSERT INTO TABLE with More Fields.php @@ -0,0 +1,28 @@ +" . mysqli_error($conn); +} + +//SECOND METHOD +mysqli_query($conn, "INSERT INTO student VALUES('1002','Mike','Sam','10','sammike@gmail.com','chennai','BCA')"); +mysqli_query($conn, "INSERT INTO student VALUES('1003','Steve','Jobs','50','steve@vit.ac.in','Bangalore','MCA')"); +mysqli_query($conn, "INSERT INTO student VALUES('1004','Andrew','Mika','22','andrew@vit.ac.in','California','MS')"); +mysqli_query($conn, "INSERT INTO student VALUES('1005','Mariyam','Mariya','25','Mariyam@vit.ac.in','istanbul','BSC')"); +mysqli_query($conn, "INSERT INTO student VALUES('1006','Ash','win','5','ash@vit.ac.in','NewYork','MSC')"); +mysqli_query($conn, "INSERT INTO student VALUES('1007','Diya','Jay','15','diya@vit.ac.in','London','PhD')"); +mysqli_query($conn, "INSERT INTO student VALUES('1008','Sri','M','25','sri@vit.ac.in','Ohio','MBA')"); +mysqli_query($conn, "INSERT INTO student VALUES('1009','Ashwin','win','5','ash@vit.ac.in','Vellore','MSC')"); +mysqli_query($conn, "INSERT INTO student VALUES('1010','DiyaAishwaryah','Jay','15','diya@vit.ac.in','Vellore','PhD')"); +mysqli_query($conn, "INSERT INTO student VALUES('1011','Sree','M','25','sri@vit.ac.in','Vellore','MBA')"); + +mysqli_close($conn); +?> \ No newline at end of file diff --git a/Code/PHP MySQL - INSERT INTO TABLE.php b/Code/PHP MySQL - INSERT INTO TABLE.php deleted file mode 100644 index 7f86106..0000000 --- a/Code/PHP MySQL - INSERT INTO TABLE.php +++ /dev/null @@ -1,35 +0,0 @@ -" . mysqli_error($conn); -} - -mysqli_query($conn,$sql1); -mysqli_query($conn,$sql2); - - -mysqli_close($conn); -?> \ No newline at end of file diff --git a/Code/PHP MySQL - LIKE FUNCTION -1.php b/Code/PHP MySQL - LIKE FUNCTION -1.php deleted file mode 100644 index 1c6d47a..0000000 --- a/Code/PHP MySQL - LIKE FUNCTION -1.php +++ /dev/null @@ -1,48 +0,0 @@ - Like Function with Starting "; - -$sql = "SELECT * FROM MyGuests where firstname like 'm%'"; -$result = mysqli_query($conn, $sql); - -if (mysqli_num_rows($result) > 0) { - // output data of each row - while($row = mysqli_fetch_assoc($result)) { - echo "Name : " . $row["firstname"]."
"; - } -} else { - echo "0 results"; -} - - -echo "
"; -echo "

Like Function with Ending

"; - -$sql = "SELECT * FROM MyGuests where firstname like '%y'"; -$result = mysqli_query($conn, $sql); - -if (mysqli_num_rows($result) > 0) { - // output data of each row - while($row = mysqli_fetch_assoc($result)) { - echo "Name : " . $row["firstname"]."
"; - } -} else { - echo "0 results"; -} - - - - -mysqli_close($conn); -?> \ No newline at end of file diff --git a/Code/PHP MySQL - LIKE FUNCTION -2.php b/Code/PHP MySQL - LIKE FUNCTION -2.php deleted file mode 100644 index dd54615..0000000 --- a/Code/PHP MySQL - LIKE FUNCTION -2.php +++ /dev/null @@ -1,48 +0,0 @@ - NOT Like Function with Starting "; - -$sql = "SELECT * FROM MyGuests where firstname NOT like 'm%'"; -$result = mysqli_query($conn, $sql); - -if (mysqli_num_rows($result) > 0) { - // output data of each row - while($row = mysqli_fetch_assoc($result)) { - echo "Name : " . $row["firstname"]."
"; - } -} else { - echo "0 results"; -} - - -echo "
"; -echo "

NOT Like Function with Ending

"; - -$sql = "SELECT * FROM MyGuests where firstname NOT like '%y'"; -$result = mysqli_query($conn, $sql); - -if (mysqli_num_rows($result) > 0) { - // output data of each row - while($row = mysqli_fetch_assoc($result)) { - echo "Name : " . $row["firstname"]."
"; - } -} else { - echo "0 results"; -} - - - - -mysqli_close($conn); -?> \ No newline at end of file diff --git a/Code/PHP MySQL - LIKE FUNCTION -3.php b/Code/PHP MySQL - LIKE FUNCTION -3.php deleted file mode 100644 index 33fee6e..0000000 --- a/Code/PHP MySQL - LIKE FUNCTION -3.php +++ /dev/null @@ -1,48 +0,0 @@ - UNDERSCORE Function "; - -$sql = "SELECT * FROM MyGuests where firstname like 'M__E'"; -$result = mysqli_query($conn, $sql); - -if (mysqli_num_rows($result) > 0) { - // output data of each row - while($row = mysqli_fetch_assoc($result)) { - echo "Name : " . $row["firstname"]."
"; - } -} else { - echo "0 results"; -} - - -echo "
"; -echo "

NOT UNDERSCORE Function

"; - -$sql = "SELECT * FROM MyGuests where firstname NOT like 'M__E'"; -$result = mysqli_query($conn, $sql); - -if (mysqli_num_rows($result) > 0) { - // output data of each row - while($row = mysqli_fetch_assoc($result)) { - echo "Name : " . $row["firstname"]."
"; - } -} else { - echo "0 results"; -} - - - - -mysqli_close($conn); -?> \ No newline at end of file diff --git a/Code/PHP MySQL - LIKE FUNCTION.php b/Code/PHP MySQL - LIKE FUNCTION.php new file mode 100644 index 0000000..d230858 --- /dev/null +++ b/Code/PHP MySQL - LIKE FUNCTION.php @@ -0,0 +1,67 @@ +mySQL - Like Function B% '; + +$result = mysqli_query($con, "SELECT RegNo, FirstName, Course from student WHERE COURSE LIKE 'B%'"); + +while ($row = mysqli_fetch_array($result, MYSQLI_NUM)) { + printf('%s -- %s -- %s', $row[0], $row[1], $row[2]); + echo '
'; +} + +print '
'; + +//LIKE Function -------------------------------------- +echo '

mySQL - Like Function - %H

'; +$result = mysqli_query($con, "SELECT RegNo, FirstName, Course from student WHERE COURSE LIKE '%H'"); +while ($row = mysqli_fetch_array($result, MYSQLI_NUM)) { + printf('%s -- %s -- %s', $row[0], $row[1], $row[2]); + echo '
'; +} + +print '
'; + +//LIKE Function -------------------------------------- +echo '

mySQL - Like Function - %C%

'; +$result = mysqli_query($con, "SELECT RegNo, FirstName, Course from student WHERE COURSE LIKE '%C%'"); +while ($row = mysqli_fetch_array($result, MYSQLI_NUM)) { + printf('%s -- %s -- %s', $row[0], $row[1], $row[2]); + echo '
'; +} + +print '
'; + +//LIKE Function -------------------------------------- +echo '

mySQL - Like Function - B%H

'; +$result = mysqli_query($con, "SELECT RegNo, FirstName, Course from student WHERE COURSE LIKE 'B%H'"); +//STARTS WITH B ENDS WITH H +while ($row = mysqli_fetch_array($result, MYSQLI_NUM)) { + printf('%s -- %s -- %s', $row[0], $row[1], $row[2]); + echo '
'; +} +print '
'; + +//LIKE Function -------------------------------------- +echo '

mySQL - Like Function - %CA

'; +$result = mysqli_query($con, "SELECT RegNo, FirstName, Course from student WHERE COURSE LIKE '%CA'"); + +while ($row = mysqli_fetch_array($result, MYSQLI_NUM)) { + printf('%s -- %s -- %s', $row[0], $row[1], $row[2]); + echo '
'; +} +print '
'; + +mysqli_close($con); +?> \ No newline at end of file diff --git a/Code/PHP MySQL - LIKE and WILDCARD FUNCTION.php b/Code/PHP MySQL - LIKE and WILDCARD FUNCTION.php new file mode 100644 index 0000000..f14cc4c --- /dev/null +++ b/Code/PHP MySQL - LIKE and WILDCARD FUNCTION.php @@ -0,0 +1,34 @@ +mySQL - Like Function B__% '; + +$result = mysqli_query($con, "SELECT RegNo, FirstName, Course from student WHERE COURSE LIKE 'B__%'"); + +//TWO UNDERSCORE = TWO CHARACTER +while ($row = mysqli_fetch_array($result, MYSQLI_NUM)) { + printf('%s -- %s -- %s', $row[0], $row[1], $row[2]); + echo '
'; +} + +print '
'; + +//LIKE Function -------------------------------------- +echo '

mySQL - Like Function - %_C

'; +$result = mysqli_query($con, "SELECT RegNo, FirstName, Course from student WHERE COURSE LIKE '%_C'"); + +while ($row = mysqli_fetch_array($result, MYSQLI_NUM)) { + printf('%s -- %s -- %s', $row[0], $row[1], $row[2]); + echo '
'; +} + +print '
'; +mysqli_close($con); +?> \ No newline at end of file diff --git a/Code/PHP MySQL - MYSQL_AFFECTED_ROWS.php b/Code/PHP MySQL - MYSQL_AFFECTED_ROWS.php index bca7430..38a691a 100644 --- a/Code/PHP MySQL - MYSQL_AFFECTED_ROWS.php +++ b/Code/PHP MySQL - MYSQL_AFFECTED_ROWS.php @@ -1,12 +1,11 @@ \ No newline at end of file diff --git a/Code/PHP MySQL - MYSQL_ERRNO.php b/Code/PHP MySQL - MYSQL_ERRNO.php new file mode 100644 index 0000000..7174324 --- /dev/null +++ b/Code/PHP MySQL - MYSQL_ERRNO.php @@ -0,0 +1,9 @@ + \ No newline at end of file diff --git a/Code/PHP MySQL - MYSQL_ERROR.php b/Code/PHP MySQL - MYSQL_ERROR.php index a8d5e54..07b6957 100644 --- a/Code/PHP MySQL - MYSQL_ERROR.php +++ b/Code/PHP MySQL - MYSQL_ERROR.php @@ -1,16 +1,8 @@ Errorcode: " . mysqli_errno($con)); -} - mysqli_close($con); ?> \ No newline at end of file diff --git a/Code/PHP MySQL - MYSQL_FETCH_ARRAY - 1 - NUMERIC.php b/Code/PHP MySQL - MYSQL_FETCH_ARRAY - 1 - NUMERIC.php new file mode 100644 index 0000000..8954277 --- /dev/null +++ b/Code/PHP MySQL - MYSQL_FETCH_ARRAY - 1 - NUMERIC.php @@ -0,0 +1,22 @@ +
"; +//print_r(mysqli_fetch_array($result)); +echo "


"; +// MYSQLI_NUM => Numeric array +// %S -> String +// %d -> Numeric +while ($row = mysqli_fetch_array($result, MYSQLI_NUM)) { + printf("FirstName: %s - LastName: %s - Age: %s ", $row[0], $row[1], $row[2]); + //printf("%s %s %s ", $row[0], $row[1], $row[2]); + + printf("
"); +} +mysqli_close($con); +?> \ No newline at end of file diff --git a/Code/PHP MySQL - MYSQL_FETCH_ARRAY - 2 -using WHERE.php b/Code/PHP MySQL - MYSQL_FETCH_ARRAY - 2 -using WHERE.php new file mode 100644 index 0000000..e3e5cd6 --- /dev/null +++ b/Code/PHP MySQL - MYSQL_FETCH_ARRAY - 2 -using WHERE.php @@ -0,0 +1,15 @@ +"); +} +mysqli_close($con); +?> \ No newline at end of file diff --git a/Code/PHP MySQL - MYSQL_FETCH_ARRAY - 3 - ORDER BY - 1.php b/Code/PHP MySQL - MYSQL_FETCH_ARRAY - 3 - ORDER BY - 1.php new file mode 100644 index 0000000..ec8d575 --- /dev/null +++ b/Code/PHP MySQL - MYSQL_FETCH_ARRAY - 3 - ORDER BY - 1.php @@ -0,0 +1,17 @@ +"); +} +mysqli_close($con); +?> \ No newline at end of file diff --git a/Code/PHP MySQL - MYSQL_FETCH_ARRAY - 3 - ORDER BY - 2.php b/Code/PHP MySQL - MYSQL_FETCH_ARRAY - 3 - ORDER BY - 2.php new file mode 100644 index 0000000..ed9304f --- /dev/null +++ b/Code/PHP MySQL - MYSQL_FETCH_ARRAY - 3 - ORDER BY - 2.php @@ -0,0 +1,17 @@ +"); +} +mysqli_close($con); +?> \ No newline at end of file diff --git a/Code/PHP MySQL - MYSQL_FETCH_ARRAY - NUMERIC vs ASSOCIATE.php b/Code/PHP MySQL - MYSQL_FETCH_ARRAY - NUMERIC vs ASSOCIATE.php new file mode 100644 index 0000000..ff23778 --- /dev/null +++ b/Code/PHP MySQL - MYSQL_FETCH_ARRAY - NUMERIC vs ASSOCIATE.php @@ -0,0 +1,36 @@ +Numeric Array"; +//Numeric Array +$sql = "SELECT * from student WHERE Course='PhD'"; +$result = mysqli_query($con, $sql); +while ($row = mysqli_fetch_array($result, MYSQLI_NUM)) { + echo "

"; + print_r($row); +} + +echo "



"; +echo "

Associate Array

"; +//Associate Array +$sql1 = "SELECT * from student WHERE Course='MBA'"; +$result1 = mysqli_query($con, $sql1); +while ($row1 = mysqli_fetch_array($result1, MYSQLI_ASSOC)) { + echo "

"; + print_r($row1); +} +echo '



'; +echo "

BOTH Array

"; +//BOTH(NUMERIC and ASSOCIATIVE) Array +$sql = "SELECT * from student WHERE Course='PhD'"; +$result = mysqli_query($con, $sql); +while ($row = mysqli_fetch_array($result, MYSQLI_BOTH)) { + echo "

"; + print_r($row); +} + +mysqli_close($con); +?> \ No newline at end of file diff --git a/Code/PHP MySQL - MYSQL_FETCH_ARRAY.php b/Code/PHP MySQL - MYSQL_FETCH_ARRAY.php deleted file mode 100644 index b6995a8..0000000 --- a/Code/PHP MySQL - MYSQL_FETCH_ARRAY.php +++ /dev/null @@ -1,21 +0,0 @@ -"); -print_r(mysqli_fetch_array($result)); -print ("
"); -while ($row = mysqli_fetch_array($result, MYSQL_NUM)) -{ - printf("student_ID: %u name: %s batch: %s course: %s", $row[0], $row[1], $row[2],$row[3]); - print("
"); -} -mysqli_close($con); -?> \ No newline at end of file diff --git a/Code/PHP MySQL - MYSQL_FETCH_ASSOC.php b/Code/PHP MySQL - MYSQL_FETCH_ASSOC.php index b636e57..4e08120 100644 --- a/Code/PHP MySQL - MYSQL_FETCH_ASSOC.php +++ b/Code/PHP MySQL - MYSQL_FETCH_ASSOC.php @@ -1,20 +1,17 @@ "; -echo $row[batch]; +echo $row[Location]; ?> \ No newline at end of file diff --git a/Code/PHP MySQL - MYSQL_FETCH_FIELD.php b/Code/PHP MySQL - MYSQL_FETCH_FIELD.php index e70e698..4109fa8 100644 --- a/Code/PHP MySQL - MYSQL_FETCH_FIELD.php +++ b/Code/PHP MySQL - MYSQL_FETCH_FIELD.php @@ -1,26 +1,24 @@ name . "
"; echo "Table name: " . $property->table . "
"; echo "Default value: " . $property->def . "
"; - echo "Max length: " . $property->max_length . "
"; + echo "Max length: " . $property->max_length . "
"; echo "Not NULL: " . $property->not_null . "
"; echo "Primary Key: " . $property->primary_key . "
"; - echo "Unique Key: " . $property->unique_key . "
"; - echo "Mutliple Key: " . $property->multiple_key . "
"; - echo "Numeric Field: " . $property->numeric . "
"; + echo "Unique Key: " . $property->unique_key . "
"; + echo "Mutliple Key: " . $property->multiple_key . "
"; + echo "Numeric Field: " . $property->numeric . "
"; echo "BLOB: " . $property->blob . "
"; echo "Field Type: " . $property->type . "
"; echo "Unsigned: " . $property->unsigned . "
"; - echo "Zero-filled: " . $property->zerofill . "

"; + echo "Zero-filled: " . $property->zerofill . "

"; } -mysqli_close($con); +mysqli_close($con); ?> \ No newline at end of file diff --git a/Code/PHP MySQL - MYSQL_FETCH_OBJECT.php b/Code/PHP MySQL - MYSQL_FETCH_OBJECT.php index 27cfc54..1180c6d 100644 --- a/Code/PHP MySQL - MYSQL_FETCH_OBJECT.php +++ b/Code/PHP MySQL - MYSQL_FETCH_OBJECT.php @@ -1,14 +1,13 @@ FirstName . "
"; } -$db_selected = mysqli_select_db("test",$con); $sql = "SELECT * from student"; -$result = mysqli_query($sql,$con); -while ($row = mysqli_fetch_object($result)) -{ - echo $row->name . "
"; -} -mysqli_close($con); +mysqli_close($con); ?> \ No newline at end of file diff --git a/Code/PHP MySQL - MYSQL_FETCH_ROW.php b/Code/PHP MySQL - MYSQL_FETCH_ROW.php index 5195fad..1c98226 100644 --- a/Code/PHP MySQL - MYSQL_FETCH_ROW.php +++ b/Code/PHP MySQL - MYSQL_FETCH_ROW.php @@ -1,18 +1,15 @@ Course : " . $row[0]; +echo "
"; +echo "FirstName: " . $row[1]; ?> \ No newline at end of file diff --git a/Code/PHP MySQL - MYSQL_FREE_RESULT.php b/Code/PHP MySQL - MYSQL_FREE_RESULT.php index 3aa886d..a7b9a1f 100644 --- a/Code/PHP MySQL - MYSQL_FREE_RESULT.php +++ b/Code/PHP MySQL - MYSQL_FREE_RESULT.php @@ -1,22 +1,15 @@ "); +print "
"; // Free memory -mysqli_free_result($result); -print(mysqli_num_rows($result)); -$db_selected = mysqli_select_db("asection",$con); -$sql = "SELECT * from student"; -$result = mysqli_query($sql,$con); -print_r(mysqli_fetch_row($result)); //mysqli_free_result($result); -print ("
"); -print(mysqli_num_rows($result)); -mysqli_close($con); +mysql_free_result($result); +print_r(mysqli_fetch_row($result)); //mysql_free_result($result); +print "
"; +mysql_close($con); ?> \ No newline at end of file diff --git a/Code/PHP MySQL - MYSQL_GET_CLIENT_INFO.php b/Code/PHP MySQL - MYSQL_GET_CLIENT_INFO.php index 8b52b48..a44c480 100644 --- a/Code/PHP MySQL - MYSQL_GET_CLIENT_INFO.php +++ b/Code/PHP MySQL - MYSQL_GET_CLIENT_INFO.php @@ -1,3 +1,3 @@ \ No newline at end of file +?> diff --git a/Code/PHP MySQL - MYSQL_GET_RESOURCE_TYPE.php b/Code/PHP MySQL - MYSQL_GET_RESOURCE_TYPE.php deleted file mode 100644 index 05befb3..0000000 --- a/Code/PHP MySQL - MYSQL_GET_RESOURCE_TYPE.php +++ /dev/null @@ -1,10 +0,0 @@ -"; -// prints: file -$fp = fopen("foo", "w"); -echo $fp; -echo get_resource_type($fp) ; -?> \ No newline at end of file diff --git a/Code/PHP MySQL - MYSQL_GET_SERVER_INFO.php b/Code/PHP MySQL - MYSQL_GET_SERVER_INFO.php index a912830..b1c54e1 100644 --- a/Code/PHP MySQL - MYSQL_GET_SERVER_INFO.php +++ b/Code/PHP MySQL - MYSQL_GET_SERVER_INFO.php @@ -1,4 +1,4 @@ \ No newline at end of file diff --git a/Code/PHP MySQL - MYSQL_LIST_DBS.php b/Code/PHP MySQL - MYSQL_LIST_DBS.php index 655e0fe..a313d2e 100644 --- a/Code/PHP MySQL - MYSQL_LIST_DBS.php +++ b/Code/PHP MySQL - MYSQL_LIST_DBS.php @@ -1,13 +1,15 @@ "; +while ($db = mysqli_fetch_object($db_list)) { echo $db->Database . "
"; } -mysqli_close($con); + +mysqli_close($con); ?> \ No newline at end of file diff --git a/Code/PHP MySQL - MYSQL_NUM_FIELDS.php b/Code/PHP MySQL - MYSQL_NUM_FIELDS.php index cb30c66..517e3f2 100644 --- a/Code/PHP MySQL - MYSQL_NUM_FIELDS.php +++ b/Code/PHP MySQL - MYSQL_NUM_FIELDS.php @@ -1,16 +1,21 @@
"; +$result = mysqli_query($con, "SELECT RegNo, FirstName FROM student"); +if (!$result) { + echo 'Could not run query: ' . mysqli_error($con); + exit(); +} +print mysqli_num_fields($result); ?> \ No newline at end of file diff --git a/Code/PHP MySQL - MYSQL_NUM_ROWS.php b/Code/PHP MySQL - MYSQL_NUM_ROWS.php index e8e1472..c1edc70 100644 --- a/Code/PHP MySQL - MYSQL_NUM_ROWS.php +++ b/Code/PHP MySQL - MYSQL_NUM_ROWS.php @@ -1,7 +1,6 @@ \ No newline at end of file diff --git a/Code/PHP MySQL - Min and Max Function.php b/Code/PHP MySQL - Min and Max Function.php new file mode 100644 index 0000000..1e3bd8e --- /dev/null +++ b/Code/PHP MySQL - Min and Max Function.php @@ -0,0 +1,32 @@ +mySQL - Minimum Function - AGE'; +$result = mysqli_query($con, 'SELECT MIN(Age) from student'); + +while ($row = mysqli_fetch_array($result, MYSQLI_NUM)) { + echo ' Minimum Value is : ', $row[0]; + echo '
'; +} + +print '
'; + +//Max Function -------------------------------------- +echo '

mySQL - Maximum Function - AGE

'; +$result = mysqli_query($con, 'SELECT MAX(Age) from student'); +while ($row = mysqli_fetch_array($result, MYSQLI_NUM)) { + echo ' Maximum Value is : ', $row[0]; + echo '
'; +} + +print '
'; + +mysqli_close($con); +?> \ No newline at end of file diff --git a/Code/PHP MySQL - Multiple Database.php b/Code/PHP MySQL - Multiple Database.php deleted file mode 100644 index 0bcdbb5..0000000 --- a/Code/PHP MySQL - Multiple Database.php +++ /dev/null @@ -1,12 +0,0 @@ -//Multiple databases can be used at a time. - - \ No newline at end of file diff --git a/Code/PHP MySQL - ORDER BY DESC.php b/Code/PHP MySQL - ORDER BY DESC.php deleted file mode 100644 index 8826137..0000000 --- a/Code/PHP MySQL - ORDER BY DESC.php +++ /dev/null @@ -1,27 +0,0 @@ - 0) { - // output data of each row - while($row = mysqli_fetch_assoc($result)) { - echo "id: " . $row["id"]. " - Name: " . $row["firstname"]. " " . $row["lastname"]. "
"; - } -} else { - echo "0 results"; -} - -mysqli_close($conn); -?> \ No newline at end of file diff --git a/Code/PHP MySQL - ORDER BY.php b/Code/PHP MySQL - ORDER BY.php deleted file mode 100644 index b994bb8..0000000 --- a/Code/PHP MySQL - ORDER BY.php +++ /dev/null @@ -1,27 +0,0 @@ - 0) { - // output data of each row - while($row = mysqli_fetch_assoc($result)) { - echo "id: " . $row["id"]. " - Name: " . $row["firstname"]. " " . $row["lastname"]. "
"; - } -} else { - echo "0 results"; -} - -mysqli_close($conn); -?> \ No newline at end of file diff --git a/Code/PHP MySQL - SELECT DATA - WHERE -1.php b/Code/PHP MySQL - SELECT DATA - WHERE -1.php deleted file mode 100644 index c514631..0000000 --- a/Code/PHP MySQL - SELECT DATA - WHERE -1.php +++ /dev/null @@ -1,28 +0,0 @@ - connect_error) { - die("Connection failed: " . $conn->connect_error); -} - -$sql = "SELECT id, firstname, lastname FROM MyGuests WHERE lastname='JACK'"; -$result = $conn->query($sql); - -if ($result->num_rows > 0) { - // output data of each row - while($row = $result->fetch_assoc()) { - echo "id: " . $row["id"]. " - Name: " . $row["firstname"]. " " . $row["lastname"]. "
"; - } -} else { - echo "0 results"; -} -$conn->close(); -?> \ No newline at end of file diff --git a/Code/PHP MySQL - SELECT DATA-1.php b/Code/PHP MySQL - SELECT DATA-1.php deleted file mode 100644 index 5f517ed..0000000 --- a/Code/PHP MySQL - SELECT DATA-1.php +++ /dev/null @@ -1,27 +0,0 @@ - 0) { - // output data of each row - while($row = mysqli_fetch_assoc($result)) { - echo "id : " . $row["id"]. " - Name : " . $row["firstname"]. " -eMail ID : " . $row["email"]. "
"; - } -} else { - echo "0 results"; -} - -mysqli_close($conn); -?> \ No newline at end of file diff --git a/Code/PHP MySQL - SELECT DATA-2.php b/Code/PHP MySQL - SELECT DATA-2.php deleted file mode 100644 index ec67fbb..0000000 --- a/Code/PHP MySQL - SELECT DATA-2.php +++ /dev/null @@ -1,27 +0,0 @@ - 0) { - // output data of each row - while($row = mysqli_fetch_assoc($result)) { - echo "id: " . $row["id"]. " - Name: " . $row["firstname"]. "
"; - } -} else { - echo "0 results"; -} - -mysqli_close($conn); -?> \ No newline at end of file diff --git a/Code/PHP MySQL - SELECT DATABASE.php b/Code/PHP MySQL - SELECT DATABASE.php index b100191..fd61d0d 100644 --- a/Code/PHP MySQL - SELECT DATABASE.php +++ b/Code/PHP MySQL - SELECT DATABASE.php @@ -1,6 +1,13 @@ Database was selected"; -?> \ No newline at end of file +$con = mysqli_connect("localhost", "root", "root"); +if (!$con) { + die('Could not connect: ' . mysqli_connect_error()); +} +if (mysqli_select_db($con, "myDB")) { + echo "Database Selected Successfully"; +} else { + echo "Error in Selecting Database: " . mysqli_errno($con); +} + +mysqli_close($conn); +?> diff --git a/Code/PHP MySQL - SUM - AVG - COUNT Function.php b/Code/PHP MySQL - SUM - AVG - COUNT Function.php new file mode 100644 index 0000000..e593fba --- /dev/null +++ b/Code/PHP MySQL - SUM - AVG - COUNT Function.php @@ -0,0 +1,41 @@ +mySQL - COUNT Function'; +$result = mysqli_query($con, 'SELECT COUNT(Age) from student'); +while ($row = mysqli_fetch_array($result, MYSQLI_NUM)) { + echo ' Total Count is : ', $row[0]; + echo '
'; +} + +print '
'; + +//AVERAGE Function -------------------------------------- +echo '

mySQL - AVERAGE Function

'; +$result = mysqli_query($con, 'SELECT AVG(Age) from student'); +while ($row = mysqli_fetch_array($result, MYSQLI_NUM)) { + echo ' Average is : ', $row[0]; + echo '
'; +} + +print '
'; + +//SUM Function -------------------------------------- +echo '

mySQL - SUM Function

'; +$result = mysqli_query($con, 'SELECT SUM(Age) from student'); +while ($row = mysqli_fetch_array($result, MYSQLI_NUM)) { + echo ' Sum is : ', $row[0]; + echo '
'; +} + +print '
'; + +mysqli_close($con); +?> \ No newline at end of file diff --git a/Code/PHP MySQL - TRUNCATE TABLE.php b/Code/PHP MySQL - TRUNCATE TABLE.php new file mode 100644 index 0000000..97abf8b --- /dev/null +++ b/Code/PHP MySQL - TRUNCATE TABLE.php @@ -0,0 +1,15 @@ + diff --git a/Code/PHP MySQL - TRUNCATE.php b/Code/PHP MySQL - TRUNCATE.php deleted file mode 100644 index d533d3d..0000000 --- a/Code/PHP MySQL - TRUNCATE.php +++ /dev/null @@ -1,23 +0,0 @@ - \ No newline at end of file diff --git a/Code/PHP MySQL - UPDATE.php b/Code/PHP MySQL - UPDATE.php deleted file mode 100644 index eea4038..0000000 --- a/Code/PHP MySQL - UPDATE.php +++ /dev/null @@ -1,23 +0,0 @@ - \ No newline at end of file diff --git a/Code/PHP MySQL - WILDCARD FUNCTION.php b/Code/PHP MySQL - WILDCARD FUNCTION.php new file mode 100644 index 0000000..ede2bb9 --- /dev/null +++ b/Code/PHP MySQL - WILDCARD FUNCTION.php @@ -0,0 +1,59 @@ +mySQL - WILDCARD Function B___ '; +$result = mysqli_query($con, "SELECT RegNo, FirstName, Course from student WHERE COURSE LIKE 'B__'"); +//TWO UNDERSCORE - TWO CHARACTERS +while ($row = mysqli_fetch_array($result, MYSQLI_NUM)) { + printf('%s -- %s -- %s', $row[0], $row[1], $row[2]); + echo '
'; +} + +print '
'; + +//WILDCARD Function -------------------------------------- +echo '

mySQL - WILDCARD Function - _CA

'; +$result = mysqli_query($con, "SELECT RegNo, FirstName, Course from student WHERE COURSE LIKE '_CA'"); +//ONE UNDERSCORE - ONE CHARACTERS +while ($row = mysqli_fetch_array($result, MYSQLI_NUM)) { + printf('%s -- %s -- %s', $row[0], $row[1], $row[2]); + echo '
'; +} + +print '
'; + +//WILDCARD Function -------------------------------------- +echo '

mySQL - WILDCARD Function - _C_

'; +$result = mysqli_query($con, "SELECT RegNo, FirstName, Course from student WHERE COURSE LIKE '_C_'"); +//ONE UNDERSCORE - ONE CHARACTERS +while ($row = mysqli_fetch_array($result, MYSQLI_NUM)) { + printf('%s -- %s -- %s', $row[0], $row[1], $row[2]); + echo '
'; +} + +print '
'; + +//WILDCARD Function -------------------------------------- +echo '

mySQL - WILDCARD Function - V_ll_r_

'; +$result = mysqli_query($con, "SELECT RegNo, FirstName, Location from student WHERE LOCATION LIKE 'V_ll_r_'"); +//ONE UNDERSCORE - ONE CHARACTERS +while ($row = mysqli_fetch_array($result, MYSQLI_NUM)) { + printf('%s -- %s -- %s', $row[0], $row[1], $row[2]); + echo '
'; +} + +print '
'; + +mysqli_close($con); +?> \ No newline at end of file