jeudi 5 novembre 2015

Insert to all cells when records are more than one PHP

Vote count: 0

here is my big program!

freinds, all thing is ok but problem is in 'while' line and when i have more than one record.

here we connect to database and fetch information about users that got service of another users.

<form name="form2" method="post" action="" accept-charset='UTF-8'>
<?php
$id=$fgmembersite->UserID(); 
echo "$id"; ?>

<?php
$db_host = 'localhost';
$db_name= 'site';
$db_table= 'action';
$db_user = 'root';
$db_pass = '';


$con = mysql_connect($db_host,$db_user,$db_pass) or die("خطا در اتصال به پايگاه داده");
$selected=mysql_select_db($db_name, $con) or die("خطا در انتخاب پايگاه داده");
mysql_query("SET CHARACTER SET  utf8");

$dbresult=mysql_query("SELECT tablesite.name,
                          tablesite.family,
                          tablesite.username,
                          tablesite.phone_number,
                          tablesite.email,
                          action.service_provider_comment,
                          action.price,
                          action.date,
                          job_list.job_name,
                          relationofaction.ind
                   FROM  $db_table
                   INNER JOIN job_list
                   on job_list.job_id=action.job_id 
                   INNER JOIN relationofaction
                   on relationofaction.ind=action.ind
                   INNER JOIN tablesite
                   on tablesite.id_user=action.service_provider_id AND action.customer_id='$id'",$con);

here prints all times that current user got service of another user. it may be 0 or n.

problem is here. when services are more that 1 and when i am trying to insert informations to table, first choose of vote and explain inserts to all cells.

                   while($amch=mysql_fetch_assoc($dbresult))
{?>
<?php
echo'<div dir="rtl">';
echo "نام خدمت دهنده: "."&nbsp&nbsp&nbsp".$amch["name"]." ".$amch["family"]."&nbsp&nbsp&nbsp"."شماره تماس: ".$amch["phone_number"]."&nbsp&nbsp&nbsp"."ایمیل: ".$amch["email"].'<br>'.

"شغل انجام شده: ".$amch["job_name"].'<br>'
."تاریخ انجام عملیات: ".$amch["date"].'<br>'
."هزینه ی کار: ".$amch["price"]." تومان".'<br>'
.$amch["service_provider_comment"].'<hr/>';


   echo'<label for="explain">اگر توضیحاتی برای ارائه در این باره دارید، ارائه دهید</label> <br />';
   echo'<textarea name="explain" id="explain" cols="" rows="" style="width:300 ;height:300"></textarea>'.'<br/>'; 

echo'<label for="rate">امتیاز این عملیات را ثبت نمایید: </label> <br />';
echo '<select name="vote">';
echo '<option value="عالی">عالی</option>';
echo '<option value="عالی">خوب</option>';
echo '<option value="عالی">متوسط</option>';
echo '<option value="عالی">بد</option>';
echo '</select>';
echo'<br/>';
echo '<input type="submit" name="submit" value="ارسال نظر شما"/>';

echo'<hr/>';
echo'<hr/>';
echo'</div>';

}

?>

here we say if user clicked on button, send informations to table. once again i say all thing for one record is ok, problem when occure that we have more than one record and i now problem is in 'while' but i do not know how fix this problem.

<?php
if(isset($_POST['submit']))
{ 

$db_host = 'localhost';
$db_name= 'site';
$db_table= 'action';
$db_user = 'root';
$db_pass = '';

$con = mysql_connect($db_host,$db_user,$db_pass) or die("خطا در اتصال به پايگاه داده");

mysql_query("SET NAMES 'utf8'", $con);
mysql_query("SET CHARACTER SET 'utf8'", $con);
mysql_query("SET character_set_connection = 'utf8'", $con);

$selected=mysql_select_db($db_name, $con) or die("خطا در انتخاب پايگاه داده");
$ins ="UPDATE $db_table
SET 
customer_comment='" . mysql_escape_string($_POST['explain']) . "',
vote='" . mysql_escape_string($_POST['vote']) . "'
WHERE ind=ind";
$saved=mysql_query($ins );
mysql_close($con); 


echo '<script language="javascript">';
echo 'alert("نظر شما با موفقیت ثبت شد")';
echo '</script>';
echo '<script>window.location.href = "action_perfomed_agree.php";</script>';
}
?>

here all information sends to table but if more than one record, will wrong.

asked 1 min ago

This entry passed through the Full-Text RSS service - if this is your content and you're reading it on someone else's site, please read the FAQ at http://ift.tt/jcXqJW.



Insert to all cells when records are more than one PHP

Aucun commentaire:

Enregistrer un commentaire