PDA

View Full Version : update کردن نتیجه یک جستجو



aseman_64
شنبه 14 شهریور 1388, 11:23 صبح
من یک صفحه دارم که حاصل یه دستور جستجوست .حالا میخوام توی این صفحه نمره همه ی بچه هارو به ترتیب وارد لیست کنم و save کنم .ولی هر کاری میکنم تو جدولم این نمره ها وارد نمی شن.
لطف میکنید اگه کمکم کنید.

aseman_64
شنبه 14 شهریور 1388, 22:52 عصر
ای بابا , دوست عزیز من فکر کردم شما توی پست قبلی به نتیجه رسیدی و همانطور که گفتم آجاکسی کار کردی !


\\\\\\\\\\\\\\\\\\\\\\\\\\\\
دوست من ،من که گفتم آجاکس کار نکردم . راهنماییم میکنید؟ خیلی ضروریه

__ziXet__
شنبه 14 شهریور 1388, 23:21 عصر
خب با چه کوئری ای سعی دارید نمرات رو وارد کنید؟

aseman_64
یک شنبه 15 شهریور 1388, 10:26 صبح
خب با چه کوئری ای سعی دارید نمرات رو وارد کنید؟

با دستور update میخوام نمرات رو بریزم توی جدول.مشکل اینه که من با استفاده از کد دوره search میکنم بعد میخوام با شماره قرارداد updateکنمش.که نمیشه.

__ziXet__
دوشنبه 16 شهریور 1388, 00:54 صبح
با دستور update میخوام نمرات رو بریزم توی جدول.مشکل اینه که من با استفاده از کد دوره search میکنم بعد میخوام با شماره قرارداد updateکنمش.که نمیشه.
خیلی سوالتون گنگ هست!
من کنار شما نشستم که دارید سوالتون رو اینجوری مطرح می کنید!
لطفا کدها رو بذارید

موفق باشید

aseman_64
دوشنبه 16 شهریور 1388, 12:12 عصر
خیلی سوالتون گنگ هست!
من کنار شما نشستم که دارید سوالتون رو اینجوری مطرح می کنید!
لطفا کدها رو بذارید

موفق باشید
///////////////////////////////////
کد مربوط به صفحه search.html (صفحه ای که کد دوره را وارد میکنم و آغاز جستجو)
<html dir="rtl">
<head>
<meta http-equiv="Content-Language" content="fa">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>جستجو بر اساس کد دوره</title>
<style>
<!--
a { text-decoration: none; color:#800000 }
p { word-spacing: 0; line-height: 150%; margin-top: 0; margin-bottom: 0 }
table { font-family: tahoma; font-size: 10pt; color: #000000;cellspacing: 0; cellpadding: 0 ;text-align:right }
.style2 {color: #999999}
.style3 {
color: #FFFFFF;
font-weight: bold;
}
.style5 {color: #FFFFFF}
.style6 {color: #04909D}
.style1 {font-weight: bold}
.style4 {
font-size: 12pt;
font-weight: bold;
}
-->
</style>
</head>
<body>
<table border="1" width="100%" background="images/77.bmp" height="509">
<tr>
<td>
<p>&nbsp;<html dir="rtl">

<form name="form1" method="GET" action="search_nomre1.php">

<div align="center">
<p>&nbsp; </p>
<table width="427" border="1" align="center" cellpadding="0" cellspacing="0" id="table1">
<tr>
<td width="423" bgcolor="#660000"><div align="right">
<p class="style2 style3"><span class="style5">جستجو بر اساس کد دوره </span></p>
</div></td>
</tr>
<tr>
<td bgcolor="B2DEDC">
<div align="center">
<p>&nbsp;</p>
<table border="1" width="333" id="table2" bgcolor="B2DEDC">
<tr>
<td width="75" bgcolor="B2DEDC">
<font face="Tahoma" size="2" color="#FFFFFF">&nbsp;
</font><font size="2" face="Tahoma">کد دوره<b><span lang="en-us">:</span></b> </font></td>

<td width="242" bgcolor="B2DEDC"><div align="right" class="style6"> <font face="Tahoma" size="2" color="#FFFFFF">
<input name="codedore" type="text" id="name2" size="31"></font></div></td>
</tr>
</table>
<p>&nbsp; </p>
<p>
<input name="bt1" type="submit" id="bt1" onClick="search_nomre1.php" value="جستجو">
</p>
<p>&nbsp; </p>
</div></td>
</tr>
</table>
<p class="style1">&nbsp;</p>
<p class="style1">&nbsp;</p>
<p class="style4"><a href="admin1.php">بازگشت</a></p>
<p class="style1">&nbsp;</p>
<p>&nbsp; </p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
</div>
</form>
<div align="center"></div>
</td>
</tr>
</table>
</body>
</html>

کد صفحه دوم که نتیجه جستجو را نمایش داده و نمره ها رادر این صفحه وارد میکنیم
<?php
session_start();
if($_SESSION['user']!="admin")
die('access denied');
$u=$_SESSION['user'];
?>
<html dir="rtl">
<head>
<meta http-equiv="Content-Language" content="fa">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>New Page 1</title>
<style>
<!--
a { text-decoration: none; color:#800000 }
p { word-spacing: 0; line-height: 150%; margin-top: 0; margin-bottom: 0 }
table { font-family: tahoma; font-size: 10pt; color: #000000;cellspacing: 0; cellpadding: 0 ;text-align:center }
.style8 {color: #FFFFFF}
-->
</style>
</head>
<body>
<?php
$link = mysql_connect("localhost","root","");
if (!$link)
die(mysql_error());
mysql_select_db("aramdb",$link) or die(mysql_error());
$n=$_GET['codedore'];
$id_gharar=$_GET['id_gharar'];
$query="select * from sabtenam where codedore='{$n}' ";
$result=mysql_db_query(aramdb,$query,$link);
/*$rows=mysql_fetch_array($result);
//$id=$rows[number];
$num = mysql_num_rows($result);
if($num<1)
{
?>
<script language="javascript" >alert("not code.");
</script>
<?php
echo "<script>window.location='search.html'</script>";
} */
$count=1;

?>
<div align="center">
<table border="0" width="754" cellspacing="0" cellpadding="0" id="table1">
<tr>
<td>
<form method="POST" action="c_final.php">
<p>&nbsp;</p>
<div align="center">
<table border="1" width="611" cellspacing="1" bordercolor="#006699" id="table2" >
<tr>
<td width="65" bgcolor="#660000"><span class="style8">نام</span></td>
<td bgcolor="#660000"><font color="#FFFFFF">نام خانوادگی </font></td>
<td width="73" bgcolor="#660000"><span class="style8">نام پدر</span></td>
<td width="117" bgcolor="#660000"><font color="#FFFFFF">شماره قرارداد</font></td>
<td width="116" bgcolor="#660000"><font color="#FFFFFF">نمره</font></td>


</tr>
<?php while($rows=mysql_fetch_array($result)){
if($count%2) $bgcolor="#C0C0C0"; else $bgcolor="#EBEBEB";
?>
<tr>
<td width="65" bgcolor="<?php echo($bgcolor); ?>"><?php echo"$rows[name]" ?></td>
<td width="212" bgcolor="<?php echo($bgcolor); ?>"><?php echo("$rows[family]") ?></td>
<td width="73" bgcolor="<?php echo($bgcolor); ?>"><?php echo"$rows[father]" ?></td>
<td width="117" bgcolor="<?php echo($bgcolor); ?>"><?php echo("$rows[id_gharar]") ?></td>
<td width="116" bgcolor="<?php echo($bgcolor); ?>">
<input name="nomre" type="text" value="<?php echo("$rows[nomre]") ?>" size="14"></td>

</tr>
<?php $count++; }; ?>
</table>
</div>
<p align="center">
<input type="submit" name="B1" value="ثبت تغییرات" onClick="c_final.php">
</p>
</form>
<p></td>
</tr>
</table>
</div>
</body>
</html>
<?php
?>

کد های صفحه ای که عمل updateرا انجام میدهد.
<!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>Untitled Document</title>
</head>
<body>
<?php
$link = mysql_connect("localhost","root","");
if (!$link)
die(mysql_error());
mysql_select_db("aramdb",$link) or die ('I cannot connect to the database because: ' . mysql_error());

if($_POST[B1]=='ثبت تغییرات'){
$id_gharar = $_POST['id_gharar'];
$name= $_POST['name'];
$family= $_POST['family'];
$father= $_POST['father'];
$nomre= $_POST['nomre'];

$q1="update sabtenam set id_gharar='{$id_gharar}' , name='{$name}' , family='{$family}' , father='{$father}' , nomre='{$nomre}' where id_gharar='{$id}'";
//echo "$q1<br>";
$res1 = mysql_query($q1, $link);
if(!$res1)
die(res1 .mysql_error());
?>
<script language="javascript" >alert("به روز رسانی با موفقیت انجام شد.");
</script>
<?php
echo "<script>window.location='show nomre.php'</script>";
}

?>

</body>
</html>


دیگه از این کامل تر چی بگم . امیدوارم بتونین کاری بکنید واسم.
ممنون!!!!!!!

__ziXet__
دوشنبه 16 شهریور 1388, 18:58 عصر
اگه این کدهارو تو تگ های php و html میذاشتی بهتر بود!
درباره کد Update:
چرا برای آپدیت کردن همه مقادیر رو تو براکت گذاشتی؟

$q1="update sabtenam set id_gharar='{$id_gharar}' , name='{$name}' , family='{$family}' , father='{$father}' , nomre='{$nomre}' where id_gharar='{$id}'";id در دیتابیس به صورت {id} ذخیره شده که اینطوری نوشتی؟
فکر کنم این کوئری درست باشه:

$q1="UPDATE sabtenam SET id_gharar='".$id_gharar."' , name='".$name."' , family='".$family."' , father='".$father."' , nomre='".$nomre."' WHERE id_gharar=".$id;موفق باشید