Temos pavadinimas: WordPress, Shopify ir PHPFusion programuotojų bendruomenė :: Updating data in mysql neveikia

Parašė cropp· 2012 Sau. 22 21:01:26
#1

Sveiki, radau tokį straipsnį

http://www.phpeasystep.com/mysql...

ir pagal jį darau viską, tačiau man kažkodėl neatsinaujina informacija duomenų bazėje gal kas nors galėtų pasakyti kodėl neatsinaujina informacija?

Mano kodai:


<?php
 
require_once 'maincore.php';
require_once THEMES.'templates/header.php';
 
opentable('Turnyrine lentele');
 
$sql="SELECT * FROM test_mysql";
$result=mysql_query($sql);
?>
<table width="400" border="0" cellspacing="1" cellpadding="0">
<tr>
<td>
<table width="400" border="1" cellspacing="0" cellpadding="3">
<tr>
<td colspan="4"><strong>List data from <span style="border-bottom: 1px dotted black;">mysql</span> </strong> </td>
</tr>
 
<tr>
<td align="center"><strong>Name</strong></td>
<td align="center"><strong>Lastname</strong></td>
<td align="center"><strong>Email</strong></td>
<td align="center"><strong>Update</strong></td>
</tr>
<?php
while($rows=mysql_fetch_array($result)){
?>
<tr>
<td><? echo $rows['name']; ?></td>
<td><? echo $rows['lastname']; ?></td>
<td><? echo $rows['email']; ?></td>
 
 
<td align="center"><a href="update.php?id=<? echo $rows['id']; ?>">update</a></td>
</tr>
<?php
}
?>
</table>
</td>
</tr>
</table>
<?php
closetable();
require_once THEMES.'templates/footer.php';
?>
 



<?php
 
require_once 'maincore.php';
require_once THEMES.'templates/header.php';
 
opentable('Turnyrine lentele');
 
// get value of id that sent from address bar
$id=$_GET['id'];
 
// Retrieve data from database
$sql="SELECT * FROM test_mysql WHERE id='$id'";
$result=mysql_query($sql);
 
$rows=mysql_fetch_array($result);
?>
<table width="400" border="0" cellspacing="1" cellpadding="0">
<tr>
<form name="form1" method="post" action="update_ac.php">
<td>
<table width="100%" border="0" cellspacing="1" cellpadding="0">
<tr>
<td>&nbsp;</td>
<td colspan="3"><strong>Update data in <span style="border-bottom: 1px dotted black;">mysql</span></strong> </td>
</tr>
<tr>
<td align="center">&nbsp;</td>
<td align="center">&nbsp;</td>
<td align="center">&nbsp;</td>
<td align="center">&nbsp;</td>
</tr>
<tr>
<td align="center">&nbsp;</td>
<td align="center"><strong>Name</strong></td>
<td align="center"><strong>Lastname</strong></td>
<td align="center"><strong>Email</strong></td>
</tr>
<tr>
<td>&nbsp;</td>
<td align="center"><input name="name" type="text" id="name" value="<? echo $rows['name']; ?>"></td>
<td align="center"><input name="lastname" type="text" id="lastname" value="<? echo $rows['lastname']; ?>" size="15"></td>
<td><input name="email" type="text" id="email" value="<? echo $rows['email']; ?>" size="15"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input name="id" type="hidden" id="id" value="<? echo $rows['id']; ?>"></td>
<td align="center"><input type="submit" name="Submit" value="Submit"></td>
<td>&nbsp;</td>
</tr>
</table>
</td>
</form>
</tr>
</table>
 
<?
 
closetable();
require_once THEMES.'templates/footer.php';
?>
 



<?php
 
require_once 'maincore.php';
require_once THEMES.'templates/header.php';
 
opentable('Turnyrine lentele');
 
// update data in <span style="border-bottom: 1px dotted black;">mysql</span> database
$sql = "UPDATE " . test_mysql .
       " SET name='" . mysql_real_escape_string($name) .
       "', lastname='" . mysql_real_escape_string($lastname) .
       "', email='" . mysql_real_escape_string($email) .
       "' WHERE id='" . mysql_real_escape_string($id) . "'";
$result=mysql_query($sql);
 
// if successfully updated.
if($result){
echo "Successful";
echo "<BR>";
echo "<a href='list_records.php'>View result</a>";
}
 
else {
echo "ERROR";
}
 
closetable();
require_once THEMES.'templates/footer.php';
?>