我已經有會話工作來顯示子信息,我現在想要能夠編輯該信息並更新數據庫。我試過每個YouTube視頻和網站,但沒有使用$ _SESSION,它們都使用$ _POST。當數據作爲會話傳遞時更新mysql數據庫
<div class="post">
<h1 class="title">Child Details: </h1>
<p class="title"><img src=" <?php echo "".$_SESSION['sourcepath']; ?>"
</p>
<p class="title"><?php echo "".$_SESSION['ChildID']; ?></p>
<table style="width: 100%">
<tr>
<td style="width: 106px">Name</td>
<td style="width: 252px"><?php echo "".$_SESSION ['Firstname']; ?> <?php echo "".$_SESSION['Surname']; ?></td>
<td style="width: 94px">School</td>
<td><form method="post">
<br />
<textarea name="School" cols="20" rows="5"><?php echo "".$_SESSION['School']; ?></textarea></form>
</td>
</tr>
<tr>
<td style="width: 106px">Date of Birth</td>
<td><?php echo "".$_SESSION['DateOfBirth']; ?></td>
<td style="width: 94px">English</td>
<td><form method="post">
<br />
<textarea name="English" cols="20" rows="5"><?php echo "".$_SESSION['English']; ?></textarea></form>
</td>
</tr>
<tr>
<td style="width: 106px">Age</td>
<td><?php echo "".$_SESSION['Age']; ?>;</td>
<td style="width: 94px">Science</td>
<td><form method="post">
<br />
<textarea name="Science" cols="20" rows="5"><?php echo "".$_SESSION['Science']; ?></textarea></form>
</td>
</tr>
<tr>
<td style="width: 106px">Address</td>
<td><form method="post">
<br />
<textarea name="Address" cols="20" style="height: 89px"><?php echo "".$_SESSION['Address']; ?></textarea></form>
</td>
<td style="width: 94px">Maths</td>
<td><form method="post">
<br />
<textarea name="Maths" cols="20" rows="5"><?php echo "".$_SESSION['Maths']; ?></textarea></form>
</td>
</tr>
<tr>
<td style="width: 106px">Postcode:</td>
<td><?php echo "".$_SESSION['PostCode']; ?>;</td>
<td style="width: 94px">Homework</td>
<td><form method="post">
<br />
<textarea name="Homework" cols="20" rows="5"><?php echo "".$_SESSION['Homework']; ?></textarea></form>
</td>
</tr>
<tr>
<td style="width: 106px">Contact Number</td>
<td><form method="post">
<textarea name="ContactNumber" cols="20" rows="2"><?php echo "".$_SESSION['ContactNumber']; ?></textarea></form>
</td>
<td style="width: 94px">Additional</td>
<td><form method="post">
<br />
<textarea name="Additional" cols="20" rows="8"><?php echo "".$_SESSION['Additional']; ?></textarea></form>
</td>
</tr>
<tr>
<td style="width: 106px">Mother Name</td>
<td><?php echo "".$_SESSION['MotherName']; ?></td>
<td style="width: 94px"> </td>
<td> </td>
</tr>
<tr>
<td style="width: 106px"> </td>
<td> </td>
<td style="width: 94px"> </td>
<td> </td>
</tr>
<tr>
<td style="width: 106px">Last Update</td>
<td><?php echo "".$_SESSION['TimeStamp']; ?></td>
<td style="width: 94px"> </td>
<td> </td>
</tr>
<tr>
<td style="width: 106px"> </td>
<td> </td>
<td style="width: 94px"> </td>
<td> </td>
</tr>
<tr>
<td style="width: 106px">
</td>
<td>
<form method="post" action="updatetest.php">
<input type="hidden" name="id" value="<?php echo $_SESSION['ChildID']; ?>"/>
<input name="Submit" type="submit" value="Update" /></form>
</td>
<?php session_start(); ?>
<?php
$connect = mysql_connect("127.0.0.1" , "root" , "") or die ("Couldnt connect to database");
mysql_select_db("travellerfile") or die ("couldnt find the database");
$School = $_SESSION['School'];
$Maths = $_SESSION['Maths'];
$English = $_SESSION['English'];
$Science = $_SESSION['Science'];
$Homework = $_SESSION['Homework'];
$Additional = $_SESSION['Additional'];
$id = $_SESSION['ChildID'];
$q = "SELECT * FROM child WHERE ChildID = $_SESSION[ChildID]";
$result = mysql_query($q);
$person = mysql_fetch_array($result);
$u = "UPDATE child SET Maths= '$_SESSION['Maths']', Science= '$_SESSION['Science']';
?>
使用會話更新行類似於更新行,任何值 – samayo 2013-04-04 11:55:08
那麼代碼是什麼?我已經嘗試了一切,沒有任何工作。 – StephSetch 2013-04-04 11:57:45
您沒有運行更新查詢'$ u' – samayo 2013-04-04 11:58:22