Jump to content

Recommended Posts

Posted

<------------------------->

//student_edit_form.php

 

<table border=1>

<tr>

<td align=center><h1>Form Edit Student Data</h1></td>

</tr>

<tr>

<td>

<table>

<?php

include "connect.inc";

$id = $_GET['id'];

$query="SELECT * FROM student where id='$id'";

$result=mysql_query($query);

//$record=mysql_numrows($result);

?>

<?php

while ($row=mysql_fetch_array($result)){

$id = $row["id"];

$studno = $row["studno"];

$fname = $row["fname"];

$lname = $row["lname"];

$mi = $row["mi"];

$age = $row["age"];

$address = $row["address"];

$bday = $row["bday"];

$sex = $row["sex"];

$contactnum = $row["contactnum"];

$course = $row["course"];

$section = $row["section"];

}

?>

<form method="post" action="edit_data.php">

<input type="hidden" name="id" value="<?php echo $id; ?>">

<tr>

<td>Student Number</td>

<td>

<?php echo $studno; ?>

</td>

</tr>

<tr>

<td>First Name</td>

<td>

<input type="text" name="firstname"

size="40" value="<?php echo $fname; ?>">

</td>

</tr>

<tr>

<td>Last Name</td>

<td>

<input type="text" name="lastname" size="40"

value="<?php echo $lname; ?>">

</td>

</tr>

<tr>

<td>M.I </td>

<td>

<input type="text" name="mi" size="40"

value="<?php echo $mi; ?>">

</td>

</tr>

<tr>

<td>Age</td>

<td>

<input type="text" name="age" size="40"

value="<?php echo $age; ?>">

</td>

</tr>

<tr>

<td>Address </td>

<td>

<input type="text" name="address" size="40"

value="<?php echo $address; ?>">

</td>

</tr>

<tr>

<td>Birthday </td>

<td>

<input type="text" name="bday" size="40"

value="<?php echo $bday; ?>">

</td>

</tr>

<tr>

<td>Sex </td>

<td>

<input type="text" name="sex" size="40"

value="<?php echo $sex; ?>">

</td>

</tr>

<tr>

<td>Status </td>

<td>

<input type="text" name="status" size="40"

value="<?php echo $status; ?>">

</td>

</tr>

<tr>

<td>Contact Number</td>

<td>

<input type="text" name="contactnum" size="40"

value="<?php echo $contactnum?>">

</td>

</tr>

<tr>

<td>Course </td>

<td>

<input type="text" name="course" size="40"

value="<?php echo $course; ?>">

</td>

</tr>

<tr>

<td>Section </td>

<td>

<input type="text" name="section" size="40"

value="<?php echo $section; ?>">

</td>

</tr>

<tr>

<td align="right">

<input type="submit"

name="submit value" value="Edit">

</td>

</tr>

</form>

</table>

</td>

</tr>

</table>

 

<------------------------------->

// edit_data.php

<?php

include "connect.inc";

$query = "UPDATE student

SET stuno='$studno',

fname='$fname',

lname='$lname',

mi='$mi',

age='$age',

address='$address',

bday='$bday',

sex='$sex',

contactnum='$contactnum',

course='$course',

section='$section'

WHERE id='$id'";

@mysql_query($query);

 

header("location:edit_stud_info.php");

?>

<-------------->

 

need help here pls it doesn't save to my database

Posted

maybe try this

 

$query = "UPDATE student

SET stuno='{$studno}', .....";

 

so put your ids within those curly brakets as if you don't then your ids are treated as string (normal text);

 

I think if you change WHERE id='1'; you will see what I mean (if i'm right that is)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...