Give me a easy example of grid insert delete update in php like mysql grid db

Ok so you have a mysql database.. like this...

_____________________________
|   id   | username | pass  |
------------------------------
|    1   |    dog   | dogs  |
|    2   |  retard  |  moo  |
|    3   |   yoyo   | ruff  |
|    4   |   coder  | bryan |
-----------------------------

now you want to change the password of the user coder
you would first connect to the database, google it, and then you would do...

mysql_query("UPDATE table SET pass = '$New_Password'
WHERE username ='coder'");

Now if you want to insert a new user into the database

mysql_query("INSERT INTO table (username, pass)
VALUES ('rodger', 'timy')");

Result =

_____________________________
|   id   | username | pass  |
------------------------------
|    1   |    dog   | dogs  |
|    2   |  retard  |  moo  |
|    3   |   yoyo   | ruff  |
|    4   |   coder  | bryan |
|    5   |  rodger  |  timy |
-----------------------------

Now whenever your setting up a login/registration system. Always make an ID class in your database's table. Make it an int that auto increments and is set to 11, that way, it will always make the next id in line, so say you have 200 users, the next person will automatically get 201

no your example for separate pages. but i want to add delete edit in one page like click on edit image or button so edit only one row i am search code this grid but its very difficult to understand..

let me give this a try...

Something like this?

<html>
<head>
	<?php require_once 'delete.php'; ?>
	<?php require_once 'update.php'; ?>
</head>
<body>
	
	<h3>View the mysql database</h3>
	
		<!-- Show mysql rows -->
	
	<h3>Edit the mysql row</h3>
	
		<!-- Run update.php with text field -->
	
	<h3>Remove a mysql row</h3>
	
		<!-- Run delete.php with a button -->

</body>
</html>

problem solve now.
if any one should help so see this example like grid mysql editor

<head>
<link href="mystyle.css" rel="stylesheet" type="text/css">
</head>
<h1>Register Courses By Teacher</h1> 


<form name="form1" method="post" action="teachers_search.php">
  <table width="367" border="2" align="center" cellpadding="2" cellspacing="2">
    <tr>
      <td width="171">Course ID  </td>
      <td width="174"><label>
        <input name="course_id" type="text" id="course_id">
      </label></td>
    </tr>
    <tr>
      <td>Teacher ID </td>
      <td><label>
        <input name="id" type="text" id="id" />
      </label></td>
    </tr>
    <tr>
      <td>Full Name </td>
      <td><label>
        <input name="name" type="text" id="name" />
      </label></td>
    </tr>
    <tr>
      <td>Course Number</td>
      <td><input name="course" type="text" id="course" /></td>
    </tr>
    
    <tr>
      <td><input type="submit" name="Submit" value="Enroll"/></td>
      <td>&nbsp;</td>
    </tr>
  </table>
</form>

<?php

if (!empty($_POST['name']))
{
$insert="insert into teacher(Course_Id,Teacher_Id,Full_Name,Course_Number) values ('$_POST[course_id]','$_POST[id]','$_POST[name]','$_POST[course]')";
include_once("connect.php");

if(!mysql_query($insert))
{
die('error in insert query');
header("Location: teachers_search.php"); 
}
else
{
echo"<br/><br/>";
header("Location: teachers_search.php"); 
echo("<b> 1 Record added </b> ");
}
}
?>

<?php
include_once("connect.php");
if($search=mysql_query("select * from teacher"))
{
//echo "<br/>";
echo "<table border='1'>
<tr>
<th>Course ID</th>
<th>Teacher ID</th>
<th>Full Name</th>
<th>Courses Number</th>
<th>Edit</th>
<th>Delete</th>
</tr>";
while($row=mysql_fetch_array($search))
{
echo "<tr>";
echo "<tr>";
echo "<td>".$row['Course_Id']."</td>";
echo "<td>".$row['Teacher_Id']."</td>";
echo "<td>".$row['Full_Name']."</td>";
echo "<td>".$row['Course_Number']."</td>";

echo '<td><a href="teachers_update.php?Course_Number=' . $row['Course_Number'] . '"><img src="images/edit.gif" /></a></td>';
echo '<td><a href="teachers_delete.php?Course_Id=' . $row['Course_Id'] . '"><img src="images/delete.gif" /></a></td>';
echo "</tr>";
}
echo "</table>";
}

?>

You can also do

$query1=" the query"
$query2=" the 2nd qury"

mysql_query($query1);
mysql_query($query2);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.