close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

update mysql form select value

Thread began 4/21/2018 2:46 pm by anonymous | Last modified 4/23/2018 3:53 pm by anonymous | 64 views | 1 replies

anonymous

update mysql form select value

hi
i want update data mysql to select value
just no update?
please help me?


if(isset($_POST['Submit']))
{
$sql=("SELECT * FROM dars
WHERE

major like '%$major%'
and sal like '%$sal%'
and type2 like '%$type2%'
and type like '%$type%'
and title like '$title%'
and vahed like '%$vahed%'
and nimsal like '%$nimsal%'");
$result=mysql_query($sql,$con);
$n=1;
<?php
if (mysql_num_rows($result) > 0)
{
?>

<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">

<?php
while($row=mysql_fetch_assoc($result))
{
echo $n++ . " ----- " //. " darsid: "?>
<input type="hidden" name="darsid[]" value="<?php $row['darsid']; ?>"/>

sal : <select name="sal[]">
<option value="اول دبیرستان"<?php if($row['sal']=='اول دبیرستان') echo 'selected="selected"'; ?>>اول دبیرستان </option>
<option value="دوم دبیرستان"<?php if($row['sal']=='دوم دبیرستان') echo 'selected="selected"'; ?>>دوم دبیرستان </option>
<option value="سوم دبیرستان"<?php if($row['sal']=='سوم دبیرستان') echo 'selected="selected"'; ?>>سوم دبیرستان </option>
</select>
major : <select name="major[]">
<option value="کامپیوتر"<?php if($row['major']=='کامپیوتر') echo 'selected="selected"'; ?>>کامپیوتر </option>
<option value="حسابداری"<?php if($row['major']=="حسابداری")echo 'selected="selected"'; ?>>حسابداری </option>
<option value="برق"<?php if($row['major']=='برق') echo 'selected="selected"'; ?>>برق </option>
</select>
type2: <select name="type2[]">
<option value="عمومی"<?php if($row['type2']=='عمومی') echo 'selected="selected"'; ?>>عمومی </option>
<option value="تخصصی"<?php if($row['type2']=='تخصصی') echo 'selected="selected"'; ?>> تخصصی</option>
</select>
type: <select name="type[]">
<option value="تئوری"<?php if($row['type']=='تئوری') echo 'selected="selected"'; ?>>تئوری </option>
<option value="عملی"<?php if($row['type']=='عملی') echo 'selected="selected"'; ?>> عملی</option>
</select>
title: <input type="text" name="title[]" value="<?php echo $row['title']; ?>"/>
vahed: <select name="vahed[]">
<option value="1"<?php if($row['vahed']=='1') echo 'selected="selected"'; ?>>1</option>
<option value="2"<?php if($row['vahed']=='2') echo 'selected="selected"'; ?>>2 </option>
<option value="3"<?php if($row['vahed']=='3') echo 'selected="selected"'; ?>>3 </option>
<option value="4"<?php if($row['vahed']=='4') echo 'selected="selected"'; ?>>4 </option>
</select>
nimsal <select name="nimsal[]">
<option value="1"<?php if($row['nimsal']=='1') echo 'selected="selected"'; ?>>نیمسال اول</option>
<option value="2"<?php if($row['nimsal']=='2') echo 'selected="selected"'; ?>>نیمسال دوم </option>
<option value="3"<?php if($row['nimsal']=='3') echo 'selected="selected"'; ?>>کامل </option>
</select>

<?php

echo "<br>";



}
}


}?>
<input type="submit" name="edit" value="edit">
</form>
<?php

if(isset($_POST['edit']))
{

$size = count($_POST['darsid']);
$i = 0;
while ($i < $size) {
$id1=$_POST['darsid'][$i];
$sal1=$_POST['sal'][$i];
$major1=$_POST['major'][$i];
$type21=$_POST['type2'][$i];
$type1=$_POST['type'][$i];
$title1=$_POST['title'][$i];
$vahed1=$_POST['vahed'][$i];
$nimsal1=$_POST['nimsal'][$i];

$sql2="Update dars set
sal='$sal1',major='$major1',type2='$type21',type='$type1',title='$title1',vahed='$vahed1',
nimsal='$nimsal1'
Where darsid='$id1'";

mysql_query($sql2) or die ("Error in query: $query");


++$i;
}
}
?>

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...