2
Contributors
5
Replies
7
Views
6 Years
Discussion Span
Last Post by G&G Designing
0

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

Edited by G&G Designing: n/a

0

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..

0

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>

Edited by G&G Designing: n/a

0

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>";
}

?>

Edited by jabeen111: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.