here is my big program!
note: all codes are in one page.
freinds, all thing is ok but problem is in \'while\' line and when i ha
I would advise wrapping each portion in its own form:
<?php
$id = $fgmembersite->UserID();
echo "$id";
$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);
$i = 1;
while($amch=mysql_fetch_assoc($dbresult)){
echo "<form id='form_$i' method='post' action='{$_SERVER['PHP_SELF']}' accept-charset='UTF-8'>\r\n";
echo '<div dir="rtl">';
echo "نام خدمت دهنده: "."   ".$amch["name"]." ".$amch["family"]."   "."شماره تماس: ".$amch["phone_number"]."   "."ایمیل: ".$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>';
echo "</form>\r\n";
$i++;
}
?>
You will find a number of little fixes in this code. This will result in a number of forms, each with a unique ID, posting to the same place.
With respect to @Twisty answer, I would like to come with my final solution to your submission problem.
First of all we need to define which raw to be updated, therefore you need to tell your update statement which ind to be updated.
To do that we need to pass ind in out submission form to out update statement, we added a hidden input field and pass out ind value like this.
<input type="hidden" name="ind" value="' . $amch["ind"] . '">;
Next we need to fetch the value and update our data by adding following:
($_POST['ind'])
So the final solution will look like this:
echo '</select>';
echo '<input type="hidden" name="ind" value="' . $amch["ind"] . '">'; //new line
echo '<br/>';
echo '<input type="submit" name="submit" value="ارسال نظر شما"/>';
echo '<hr/>';
echo '<hr/>';
and in your update statement:
$ins = "UPDATE $db_table
SET
customer_comment='" . mysql_escape_string($_POST['explain']) . "',
vote='" . mysql_escape_string($_POST['vote']) . "'
WHERE ind=".($_POST['ind']); // to define the ind value
And wala, it works.
NOTE:
Just be a ware of, I used the updated code of @Twisty and the final solution on it.