Home Discussion Discuss: MySQL PHP Query delete

  • ple's tell the delete rowprasad December 6, 2011 at 11:03 AM

    <script type="application/javascript"> function getdetails(name,email,age,mobile,gender,buttonname) { document.getElementById("txtName").value=name; document.getElementById("txtEmail").value=email; document.getElementById("txtAge").value=age; document.getElementById("txtMobile").value=mobile; document.getElementById("submit").value=buttonname; } function removeRowFromTable() { var tbl = document.getElementById('tbl_Registration'); var lastRow = tbl.rows.length; if (lastRow > 2) tbl.deleteRow(lastRow - 1); } </script> <?php mysql_connect("localhost","root",""); mysql_select_db("test"); $btnValue = "Submit"; if(isset($_POST['submit'])) { $Submit = $_POST['submit']; //here we are checking Button value if button value Submit then Values insert into Database if($Submit=="Submit") { $Name = $_POST['txtName']; $Email = $_POST['txtEmail']; $Mobile = $_POST['txtMobile']; $Age = $_POST['txtAge']; $Gender = $_POST['rbGender']; /* *Here i am checking Mobile number in database *if $count =0 then record will insert in database other wise it will dispaly the error message ... */ $query = "Select id from tbl_Registration where mobile='$Mobile'"; $res = mysql_query($query); $count = mysql_num_rows($res); //Inserting if($count==0) { if($Name=="") { echo "Please Enter Valide Name"; } else { $qry = "insert into tbl_Registration(name,email,mobile,age,gender) Values('$Name','$Email','$Mobile','$Age','$Gender')"; $res1 = mysql_query($qry); if($res1) { echo "Inserted Successfully"; } else { echo "Not Inserted"; } } } else { echo "Mobile Number already existed"; } } //Update Coding else { $Id = $_GET[id]; $Name =$_POST['txtName']; $Email =$_POST['txtEmail']; $Mobile =$_POST['txtMobile']; $Age =$_POST['txtAge']; $Gender =$_POST['rbGender']; /*$query= "Selete id from tbl_Registration where mobile='$Mobile'"; $res= mysql_query(query); $count = mysql_num_rows($res); if($count==0 || $count==1) {*/ if(Name=="") { echo"Please Enter Valid Name"; } else { $qry="UPDATE tbl_Registration set name ='$Name',email='$Email',age='$Age',mobile='$Mobile',gender='$Gender' where id='$Id';"; $res= mysql_query($qry); if($res) { echo"Updated successfully"; } else { echo"Not updated"; } } /*} else { echo "Mobile Number Already esited..."; }*/ } } //Database values Retriving Start... //Select Query $selectQry = "select * from tbl_registration"; $selectRes = mysql_query($selectQry); $selectRow = mysql_fetch_array($selectRes); echo "<table border='1'> <tr> <th>id</th> <th >Name</th> <th >Email</th> <th >Mobile</th> <th >Age</th> <th >Gender</th> <th >Modify</th> <th >Delete</th> </tr>"; $count=0; while($selectRow = mysql_fetch_array($selectRes)) { $count=$count+1; echo "<tr> <td>$count </td> <td >$selectRow[1]</td> <td >$selectRow[2] </td> <td >$selectRow[3]</td> <td >$selectRow[4]</td> <td >$selectRow[5] </td> <td><a href=\"javascript:getdetails('$selectRow[1]','$selectRow[2]','$selectRow[3]','$selectRow[4]','$selectRow[5]','Update')\">Edit</a></td> <td><a href=\"javascript:deleteRow('$selectRow[1]','$selectRow[2]','$selectRow[3]','$selectRow[4]','$selectRow[5]',)\">Delete</a></td> </tr> "; } echo "</table><br><br>"; //Database values Retrived end... //Code Start //Here i am getting the ID from url.. //And dispaling the values based on ID into Controls $uid=$_GET[id]; if(isset($_GET[id])) { $btnValue="Update"; $id = $_GET['id']; $query1 = "Select * from tbl_Registration where id=$id"; $res1 = mysql_query($query1); $values = mysql_fetch_array($res1); } //Code End ?> <html> <body> <form name="frmRegistration" method="post" action="" onSubmit="return Validation()"> <table id="tblReg"> <tr> <td>Name *</td> <td> <input type="text" name="txtName" id="txtName" value=""/> </td> </tr> <tr> <td>Email *</td> <td> <input type="text" name="txtEmail" id="txtEmail" value=""/> </td> </tr> <tr> <td>Phone *</td> <td> <input type="text" name="txtMobile" id="txtMobile" value=""/> </td> </tr> <tr> <td>Age</td> <td> <input type="text" name="txtAge" id="txtAge" value=""/> </td> </tr> <tr> <td>Gender</td> <td> <input type="radio" name="rbGender" id="rbGender" value="Male" <?php if($values[5]=="Male"){echo "checked";}?>/>Male <input type="radio" name="rbGender" id="rbGender" value="Female" <?php if($values[5]=="Female"){echo "checked";}?>/>Female <input type="button" value="Delete [D]" onClick="deleteChecked();" /> </td> </tr> <tr> <td> <input id="submit" name="submit" type="submit" value="<?php echo $btnValue;?>" /> </td> </tr> </table> </form> </tr> </table> </body> </html>

  • aaaaaa January 11, 2012 at 2:23 PM

    <script>alert('document.cookie');</script>

  • php developersROCKESH RONITH February 15, 2012 at 6:28 PM

    very nice !!! but its not more helpful for beginners...

Post your Comment



Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Related Articles
SQL Tutorial

MySQL PHP Query delete
MySQL PHP Query delete       Mysql PHP Query delete is used to execute Mysql function ( ) delete query from a database table. MySQL PHP Query is used to delete the records 

SQL Tutorial

MySQL PHP Query delete
MySQL PHP Query delete       Mysql PHP Query delete is used to execute Mysql function ( ) delete query from a database table. MySQL PHP Query is used to delete the records 

PHP Questions

delete row
= $checkbox[$i]; mysql_query("delete from sonu where id='$delete...delete row  how to delete row using checkbox and button in php... is ..... <?php $link=mysql_connect("localhost", "root", ""); mysql_select_db 

JSP Servlet Questions

delete
delete  how delete only one row in the database using jsp.database is mysql   Hi Friend, Try the following code: 1)user.jsp: <%@ page...;/tr> <% Connection con = null; String url = "jdbc:mysql://localhost:3306 

Hibernate Questions

Delete Query using HQL
Delete Query using HQL  Can we write 'AND' with 'WHERE' clause in delete query using HQL? For example: delete from table name where field1... a look at the following link: Hibernate Delete Query 

Hibernate Questions

delete query problem - Hibernate
delete query problem  SessionFactory fact = new Configuration... correctly , the problem is only delete query. 2) query.executeUpate(); ->..., String hql = "delete from Insurance insurance where id = 2"; Query 

EJB Questions

JPA delete query - EJB
JPA delete query  Hi, I have an entity InvoiceItems.java. I want to delete all the records from the table. What will be the JPA query to delete... to achieve this: Query query = em.createQuery("delete from InvoiceItems o 

Hibernate Questions

Delete HQL query - Hibernate
Delete HQL query  Hi I am trying hibernate tutorial. But delete HQL tutorial not working properly. It gives null pointer exception. Query class has method executeUpate() & not executeUpdate(); log4j:WARN No appenders 

Hibernate Questions

hibernate delete query :
hibernate delete query :   Hi, I m using Hibernate 3 + javadb my... NOT NULL , ITEM_ID INTEGER NOT NULL ) I want to delete a row from table...(); org.hibernate.Transaction tx = session.beginTransaction(); String query1 = "delete from 

PHP Tutorial

PHP MySQL Delete
PHP MySQL Delete:       In SQL...;age']."<br/>"; } mysql_query("delete from student where...;?php $db=mysql_connect("localhost","root","" 

PHP Questions

php delete checkbox
php delete checkbox  How can i delete the data with multiple check boxes in PHP 

PHP Questions

query
query  how to design the web site in PHP 

PHP Questions

php query
php query  i have a basic index and a login.php page in the web root , but i would like to place it in some other folder .. what modifications do i need to do in index page 

Java Beginners

query
query  how to delete checked record into database using checkbox...:mysql://localhost:3306/mysql","root", "root"); ResultSet rs = null; Statement...:mysql://localhost:3306/mysql","root", "root"); ResultSet rs = null; Statement st 

SQL Question

Write a query to delete a record from a table
Write a query to delete a record from a table  Write a query to delete a record from a table   Hi, The query string for the delete operation is as follows- delete from employee where id='35'; Thanks 

Hibernate-Tutorials

Hibernate delete Query
Hibernate delete Query In this tutorial you will learn how to use HQL delete query in Hibernate. In this section we are discussing about the HQL delete query... to use HQL delete query. An example is being given regarding how delete query may 

PHP Questions

php show last query
php show last query  How to show the last updated record from the database in PHP? Is there any query that i need to write in the php script 

PHP Questions

PHP MySQL query
PHP MySQL query  I have 11 tables and have to do the CRUD operations keeping userid as a reference key 

PHP Questions

project on php and query
project on php and query  ,,,write code thats i have five tabels and i must make them as forms html then link between them database and php them make query betwen them this five tabels Table of suppliers Source no resource 

Hibernate-Tutorials

Hibernate Delete Query
In this section we will discuss how to delete record of table using HQL 

PHP Tutorial

php array delete element
is optional.If not given all elements get removed PHP Array Delete Element Example <?php     $ar1=array("aaa","bbb","ccc","ddd","eee 

PHP Questions

delete record
delete record  how to delete record using checkbox and button in php...("com.mysql.jdbc.Driver").newInstance(); conn = DriverManager.getConnection("jdbc:mysql://localhost...").newInstance(); conn = DriverManager.getConnection("jdbc:mysql://localhost 

Hibernate Tutorial Example

Hibernate Delete Query
Hibernate Delete Query      ... (DeleteHQLExample.java), which we will delete a row from the insurance table using the query...;2" Here is the code of delete query: DeleteHQLExample.java  

PHP Questions

php
php  plz tell me code for PHP SQL Insert,delete,update,view is used to insert the record from HTML page to Mysql database using in single PHP form 

PHP Tutorial

Delete Cookie
Delete Cookies In the following program, you will learn how to delete the cookie through setting session.  In the given example, we have set the value....  <?php $expire=time()+60*60*24*30; setcookie("cookie", " 

MySQL

PHP SQL Query Insert
PHP SQL Query Insert       This example illustrates how to execute insert query in php...). Now, queries can be executed using mysql_query() method to insert values 

PHP Questions

php
can learn php mysql connectivity examples from the given link: PHP Mysql Connectivity.... the program is whenever i execute it I get message as:Query failed 

Hibernate Questions

Hibernate delete HQL - Hibernate
Hibernate delete HQL  Hi I am trying hibernate tutorial. But delete HQL tutorial not working properly. It gives null pointer exception. Query class has method executeUpate() & not executeUpdate 

PHP

Php Sql Query Insert
Php Sql Query Insert  This example illustrates how to execute insert query with values in php application. In this example we create two mysql query...; <?php   $con = mysql_connect("localhost","root 

SQL Question

sql query
numbers of sids.i want to delete the sid based on the mid.for that i need sql query plz help to me 

DMCA.com