Php Practical Programs

PHP PRACTICAL PROGRAMS:


QUESTION:

  Consider the following entities and their relationships

    Event (eno , title , date )

    Committee ( cno , name, head , from_time ,to_time , status)

  Event and Committee have many to many relationship. Write a script to accept title of event and modify status committee as working.

 

 

 

HTML PROGRAM:

Event_Committee.html


<!-- program for modify status of committee as working -->


<!DOCTYPE html>

 <html>

  <head> <title> mysql Event </title> </head>

  

  <body bgcolor="navyblue">

   <form action = "Event_Committee.php" method = "POST">

   <label for="ename">Enter the name of Event: </label>

   <input type = "text" name = "ename" id = "ename"> <BR>


   <input type = "submit" value = "submit">

   <input type = "reset" value = "reset">


   </form>

  </body>

 </html>  




PHP PROGRAM:

Event_Committee.php



<?php

$name = $_POST['ename'];


$connect = mysqli_connect("localhost","root","","swapnildb");

if($connect)

echo "Successfully connect<BR>";

else

echo "Doesn't connnect";


$query = "update event,committee,event_committee set status = 'wedding' where title = '$name' and event.eno = event_committee.eno and committee.cno = event_committee.cno ";


if($query)

echo "Successfully Modify";

else

echo "Problem in Modify";



$result = mysqli_query($connect, $query);


if($result)

echo "<BR>ok";

else

echo "not ok";


?>




MYSQL QUERIES :



MariaDB [swapnildb]> create table event(eno int primary key,title varchar(30),date date);

Query OK, 0 rows affected (0.042 sec)



MariaDB [swapnildb]>insert into event values(1,'wedding','2023-01-12');

Query OK, 1 row affected (0.024 sec)


MariaDB [swapnildb]> insert into event values(2,'party','2023-02-15');

Query OK, 1 row affected (0.022 sec)


MariaDB [swapnildb]> insert into event values(3,'birthday','2023-01-26');

Query OK, 1 row affected (0.022 sec)


MariaDB [swapnildb]> insert into event values(4,'thanks giving','2023-01-01');

Query OK, 1 row affected (0.021 sec)


MariaDB [swapnildb]> insert into event values(5,'Alumni event','2023-05-05');

Query OK, 1 row affected (0.022 sec)


MariaDB [swapnildb]> select * from event;

+-----+---------------+------------+

| eno  |       title        |     date       |

+-----+---------------+-------------+

|   1     |   wedding    | 2023-01-12 |

|   2     |     party        | 2023-02-15 |

|   3     |    birthday    | 2023-01-26 |

|   4     | thanks giving | 2023-01-01 |

|   5     | Alumni event  | 2023-05-05 |

+------+------------------+------------+

5 rows in set (0.001 sec)




MariaDB [swapnildb]> create table committee(cno int primary key, name varchar(20),head varchar(20),from_time date, to_time date, status varchar(20));

Query OK, 0 rows affected (0.041 sec)


MariaDB [swapnildb]> insert into committee values(11,'c1','dr.melbern','2023-01-01','2023-06-06','wedding');

Query OK, 1 row affected (0.023 sec)


MariaDB [swapnildb]> insert into committee values(12,'c2','dr.jensen','2023-01-01','2023-06-06','party');

Query OK, 1 row affected (0.020 sec)


MariaDB [swapnildb]> insert into committee values(13,'c3','dr.jamble','2023-01-01','2023-06-06','birthday');

Query OK, 1 row affected (0.022 sec)


MariaDB [swapnildb]> insert into committee values(14,'c4','dr.ladkat','2023-01-01','2023-06-06','thanks giving');

Query OK, 1 row affected (0.020 sec)


MariaDB [swapnildb]> insert into committee values(15,'c5','dr.chaudhari','2023-01-01','2023-06-06','Alumni event');

Query OK, 1 row affected (0.020 sec)


MariaDB [swapnildb]> select * from committee;

+-----+------+--------------+------------+------------+---------------+

|  cno  | name |     head     | from_time  | to_time    | status        |

+-----+------+--------------+------------+------------+---------------+

|  11 | c1   | dr.melbern    | 2023-01-01 | 2023-06-06 | wedding        |

|  12 | c2   | dr.jensen       | 2023-01-01 | 2023-06-06 | party              |

|  13 | c3   | dr.jamble      | 2023-01-01 | 2023-06-06 | birthday         |

|  14 | c4   | dr.ladkat       | 2023-01-01 | 2023-06-06 | thanks giving |

|  15 | c5   | dr.chaudhari | 2023-01-01 | 2023-06-06 | Alumni event  |

+-----+------+--------------+------------+------------+---------------+

5 rows in set (0.001 sec)





MariaDB [swapnildb]> create table event_committee(eno int ,cno int, primary key(eno,cno),foreign key(eno) references event(eno) on delete cascade , foreign key(cno) references committee(cno) on delete cascade);

Query OK, 0 rows affected (0.043 sec)


MariaDB [swapnildb]> insert into event_committee values(1,11);

Query OK, 1 row affected (0.022 sec)


MariaDB [swapnildb]> insert into event_committee values(2,12);

Query OK, 1 row affected (0.020 sec)


MariaDB [swapnildb]> insert into event_committee values(3,13);

Query OK, 1 row affected (0.021 sec)


MariaDB [swapnildb]> insert into event_committee values(4,14);

Query OK, 1 row affected (0.022 sec)


MariaDB [swapnildb]> insert into event_committee values(5,15);

Query OK, 1 row affected (0.021 sec)


MariaDB [swapnildb]> insert into event_committee values(5,11);

Query OK, 1 row affected (0.022 sec)


MariaDB [swapnildb]> select * from event_committee;

+-----+-----+

| eno | cno |

+-----+-----+

|   1 |  11 |

|   2 |  12 |

|   3 |  13 |

|   4 |  14 |

|   5 |  11 |

|   5 |  15 |

+-----+-----+

6 rows in set (0.001 sec)




php query--->

$query = "update event,committee,event_committee set status = 'earnmoney' where title = '$name' and event.eno = event_committee.eno and committee.cno = event_committee.cno ";


web -browser-->

Enter the name of Event: 

                      ----------------

     |    birthday   |

                      ----------------

  -------    -------

  submit |   |reset|

  --------   -------


MariaDB [swapnildb]> select * from committee;

+-----+------+--------------+------------+------------+---------------+

| cno | name | head         | from_time  | to_time    | status        |

+-----+------+--------------+------------+------------+---------------+

|  11 | c1   | dr.melbern   | 2023-01-01 | 2023-06-06 |  wedding      |

|  12 | c2   | dr.jensen      | 2023-01-01 | 2023-06-06 | party         |

|  13 | c3   | dr.jamble      | 2023-01-01 | 2023-06-06 | earnmoney     |

|  14 | c4   | dr.ladkat       | 2023-01-01 | 2023-06-06 | thanks giving |

|  15 | c5   | dr.chaudhari | 2023-01-01 | 2023-06-06 | Alumni event  |

+-----+------+--------------+------------+------------+---------------+

5 rows in set (0.001 sec)








php query--->


$query = "update event,committee,event_committee set status = 'wedding' where title = '$name' and event.eno = event_committee.eno and committee.cno = event_committee.cno ";



web -browser-->

Enter the name of Event: 

                      ----------------

  | Alumni event |

                      ----------------

  -------    -------

  submit |   |reset|

  --------   -------

 


MariaDB [swapnildb]> select * from committee;

+-----+------+--------------+------------+------------+---------------+

| cno | name | head         | from_time  | to_time    | status        |

+-----+------+--------------+------------+------------+---------------+

|  11 | c1   | dr.melbern    | 2023-01-01 | 2023-06-06 | wedding       |

|  12 | c2   | dr.jensen       | 2023-01-01 | 2023-06-06 | party         |

|  13 | c3   | dr.jamble      | 2023-01-01 | 2023-06-06 | earnmoney     |

|  14 | c4   | dr.ladkat       | 2023-01-01 | 2023-06-06 | thanks giving |

|  15 | c5   | dr.chaudhari | 2023-01-01 | 2023-06-06 | wedding       |

+-----+------+--------------+------------+------------+---------------+

5 rows in set (0.001 sec)


MariaDB [swapnildb]> 














Comments

Popular posts from this blog

Full Stack Developement Practical Slips Programs

Android App Developement Practicals Programs

Practical slips programs : Machine Learning