
11-10-2009, 22:24
|
|
|
|
חבר מתאריך: 07.06.04
הודעות: 23
|
|
|
יש לי סקריפט עם update וזה לא עובד
יש לי סקריפט עם update וזה לא עובד מישהו יכול לעזור ליבבקשה זה הסקריפט
טופס form.php
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=windows-1255"/>
<title>update</title>
<?PHP
$con = mysql_connect("localhost", 'root', '');
mysql_select_db('test', $con);
$result=mysql_query("SELECT * FROM user1 order by id");
echo "<table border='1'>
<tr>
<th>שם פרטי </th>
<th>שם משפחה</th>
<th>כתובת </th>
</tr>";
while ($row = mysql_fetch_array($result)) {
?>
<form method="post" action="update.php">
<tr>
<td><input name="username" type="text" value="<?php echo $row['username'] ;?>"/></td>
<td><input name="lastname" type="text" value="<?php echo $row['lastname'];?>"/> </td>
<td><input name="adress" type="text" value="<?php echo $row['adress'] ;?>"/></td>
</tr>
<?php
}
?>
<td><input name="submit" type="submit" value="update"/>
</form>
</table>
<?
mysql_close($con);
?>
סקריפט עידכון
update.php
<?
if($_POST['Submit']){
$host="localhost";
$db_user="root";
$db_password="";
$database="test";.
mysql_connect($host,$db_user,$db_password);
mysql_select_db($database);
$username=$_POST['username'];
$lastname=$_POST['lastname'];
$adress=$_POST['adress'];
$query = 'SELECT * FROM user1 WHERE id='.$_GET['id'];
while($row=mysql_fetch_assoc($result)){
mysql_query("update user1 set username='$username' where id='$_GET[id]'");
mysql_query("update user1 set lastname='$lastname' where id='$_GET[id]'");
mysql_query("update user1 set adress='$adress' where id='$_GET[id]'");
}
}
?>
מה פה לא בסדר
|