PDA

View Full Version : مشکل در آبدیت رکورد های دیتابیس به صورت هم زمان



hamidhassas
دوشنبه 25 شهریور 1392, 09:37 صبح
من یک جدول دارم که در اون نام کالا وجود داره و قیمت اون کالا میخوام در یک صحفه کاری کنم که اگر قیمت های چند کالا رو تغییر دادم بعد از زدن دکمه ثبت تغییرات هم زمان اطلاعات اون رکورد ها تغییر کنه یعنی اطلاعات هم رکورد یکی یکی تغییر کنه
باید چکار کنم کدی که نوشتم به صورت زیر هست



general_connection($username,$password,$general_da tabase);
mysql_query('SET NAMES \'utf8\'');
$read= "select * from `princ_services` where `id` ORDER BY `id`";
$tab=mysql_query($read);
$row=mysql_fetch_array($tab);
@$checkbox = $_POST['checkbox'];
$count = mysql_num_rows($tab);
// اگر فرم ارسال شود کد زیر اجرا می شود
if($checkbox){
for($i=0;$i<$count;$i++){
@$del_id = $checkbox[$i];
$details=$_POST['textfield'];
$read_sql = "UPDATE `princ_services` SET `princ`='$details' WHERE `id` ='$del_id'";
$Record = mysql_query($read_sql);
}
// رفرش صفحه در صورت اجرای موفقیت آمیز کد
if($Record){
echo "<meta http-equiv=\"refresh\" content=\"0;URL=Princ.php\">";
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link href="../scripts_style/style/main_style.css" rel="stylesheet" type="text/css" />
<meta http-equiv="refresh" content="380; url=Daftar_List.php" />
</head>
<body background="../images/main_background.jpg">
<form method="post" action="" name="form">
<table align="center" class="CForm_AddItemForm" >
<thead>
<tr>
<th> انتخاب </th>
<th> ردیف </th>
<th> شرح </th>
<th> قیمت </th>
<th> وضعیت </th>
</tr>
</thead>
<tbody align="center">
<tr id="tr_calendar_reg_from">
<td align="center"><input name="checkbox[]" type="checkbox" value="<?php echo $row[0]; ?>" /></td>
<td class="input"><?php print $row[1]; ?></td>
<td class="input"><form id="form1" name="form1" method="post" action="">
<input name="textfield[]" type="text" id="textfield" value="<?php print $row[2]; ?>" size="12" />
</form></td>
</tr>
<?php while ($row=mysql_fetch_array($tab)){?>
<tr id="tr_calendar_latereg_from">
<td align="center"><input name="checkbox[]" type="checkbox" value="<?php echo $row[0]; ?>" /></td>
<td class="input"><?php print $row[1]; ?></td>
<td class="input"><input name="textfield[]" type="text" id="textfield" value="<?php print $row[2]; ?>" size="12" /></td>
</tr>
<?php } ?>
</tbody>
</table>
<input type="submit" name="button" id="button" value="ثبت تغییرات">
</form>