Auto fill text box depending on Drop Down value - javascript

This might be a stupid question but I would like to have a clarification on how to go about this. I have come across quite a few articles that let to set the values of a text box depending on the choices made in a drop down menu using jQuery and Ajax. My issue is when I'm trying to do the same depending on the choices made in 5 drop down menus. I have the Id values stored in the database which should be used to populate the text box. Can anyone guide on how to go about this issue with multiple drop downs. This is my code so far:
<?php
$sql1="SELECT Schlungen FROM schulung as s";
$result=mysql_query($sql1);
echo "<p align='left'> <strong>Schulung 1</strong> <select name='Schlungen1'> <option value default></option>";
while ($row = mysql_fetch_array($result))
{
echo "<option value='" . $row['Schlungen'] . "'>" . $row['Schlungen'] . " </option>";
}
echo "</select>";
?>
<?php
error_reporting(0);
//Drop Down for Schulung 2
$sql2="SELECT Schlungen FROM schulung as s";
$result=mysql_query($sql2);
echo "<p align='left'> <strong>Schulung 2</strong> <select name='Schlungen2'> <option value default></option>";
while ($row = mysql_fetch_array($result))
{
echo "<option value='" . $row['Schlungen'] . "'>" . $row['Schlungen'] . " </option>";
}
echo "</select>";
?>
<?php
error_reporting(0);
//Drop Down for Schulung 3
$sql3="SELECT Schlungen FROM schulung as s";
$result=mysql_query($sql3);
echo "<p align='left'> <strong>Schulung 3</strong> <select name='Schlungen3'> <option value default></option>";
while ($row = mysql_fetch_array($result))
{
echo "<option value='" . $row['Schlungen'] . "'>" . $row['Schlungen'] . "</option>";
}
echo "</select>";
?>
<?php
error_reporting(0);
//Drop Down for Schulung 4
$sql4="SELECT Schlungen FROM schulung as s";
$result=mysql_query($sql4);
echo "<p align='left'> <strong>Schulung 4</strong> <select name='Schlungen4'><option value default></option>";
while ($row = mysql_fetch_array($result))
{
echo "<option value='" . $row['Schlungen'] . "'>" . $row['Schlungen'] . " </option>";
}
echo "</select>";
?>
<?php
error_reporting(0);
//Drop Down for Schulung 5
$sql5="SELECT Schlungen FROM schulung as s";
$result=mysql_query($sql5);
echo "<p align='left'> <strong>Schulung 5</strong> <select name='Schlungen5'><option value default></option>";
while ($row = mysql_fetch_array($result))
{
echo "<option value='" . $row['Schlungen'] . "'>" . $row['Schlungen'] . " </option>";
}
echo "</select>";
?>
<p align="left"><strong>Access_level </strong>
<input type="text" name="a_level" disabled="disabled">
</p>

For achieving auto completion,you can create a select field in html file,call a javascript function on keyup event and use jQuery for calling your php file
<html>
<head>
<script>
$('.autosuggest').keyup(function(){
$.post("<your file.php>",{any data you need},function(data){
//echo the data
//echo "<option value='" . $row['Schlungen'] . "'>" . //$row['Schlungen'] ." </option>";
$('.result').html(data)
});
});
$('.result option').click(function(){
var rValue = $(this).text();
$('.autosuggest').attr('value',rValue);
$('.result').html('');
});
</script>
</head>
<body>
<input type='text' class='autosuggest'/>
<select class='result'>
</select>
</body>
</html>

try to set the value of each html select option to be the id of that text
so the echo should be
echo "<option value='" . $row['id'] . "'>" . $row['Schlungen'] . " </option>";
then on the html select add the event onchange and add the JS function foo() to fill a hidden input with all selected ids by getting them from the page using the JQuery or Javascript
also you have to add id or class for each html select to get its selected value easily
$("#select1").val();
$("#select2").val(); ...
then insert these values in a hidden input field so the hidden input now contains all selected ids

Related

how to disable checkbox after due date has passed

I've this code in php, and it retrieve all the value I've in my database, and I want the user not be able to choose or tamper with the one that has expired date,
please can you help me ?
my code below only show u the word 'Expired' and 'Not Expired' on the web, since I'm only Echoing it.
I want to just disable the check box, and not let the user be able to change anything like the statues or remove the job.
please can you help me ?
$result = mysqli_query($dbCIE,$sqlCommand) or die(mysql_error());
echo "<form action='JobsLists.php' method='post'>";
while($row = mysqli_fetch_array($result))
{
$exp_date = $row['DueDate'];
$today_date = date('Y/m/d');
$exp=strtotime($exp_date);
$td=strtotime($today_date );
if($td>$exp){
echo"Expiered";
}else{
echo"NOT Expiered";
}
echo "<tr>";
echo "<td> <input type='checkbox' id='myCheck' name='JobId[]' value='". $row['JobId'] ."' /> </td>";
echo "<td align=center>" . $row['SSU'] . "</td>";
echo "<td align=center>" . $row['JobName'] . "</td>";
echo "<td align=center> " . $row['Description'] . "</td>";
echo "<td align=center>" . $row['DueDate'] . "</td>";
echo "<td>"."<select name='JobStatus[".$row['JobId']."]'>";
if($row['JobStatus'] == "InProgress"){
echo "<option value='InProgress' selected>In Progress</option>";
echo "<option value='Completed'>Completed</option>";
} else {
echo "<option value='InProgress'>In Progress</option>";
echo "<option value='Completed' selected> Completed </option>";
}
echo "</select>" . "</td>"; // need to be worked on..
echo "</tr>";
}
"</table>";
?>
Why not just not print it out?
if (!$td->exp)
echo "<td> <input type='checkbox' id='myCheck' name='JobId[]' value='". $row['JobId'] ."' /> </td>";
It's better to just not show a button or input than to disable it sometimes. Inputs can be disabled with the DISABLED keyword
<input type="checkbox" name="foo" DISABLED>

Option in dropdown box render outside

English is not my first language so i'm trying to be as specific as possible.
I have a table stored , all of the signed up account to my website. Inside of it i have a dropdown box automatically generated by php. So the problem is, when i click to changed the option in the dropdown menu, all of my option appeared outside of the box and was duplicated . Just like this error dropdown box. Here is the code
$sql1="Select ID, user_login,user_email, display_name from wp_users ";
$result1=mysqli_query($conn,$sql1);
echo '<div id="div_package" style="display: none" >';
echo '<div style="text-align:center"><h1>Đổi gói thành viên</h1><input type="text" id="myInput_pack" onkeyup="FilterUsers()" placeholder="Nhập thông tin người dùng cần tìm" title="Type in a user" style="width: 20%;height:35px; font-size: 16px;border: 1px solid black; margin-bottom: 12px;text-align:center"></div>';
echo "<table id='tb_user' class='tbadmin' border='1' cellpadding='10' align='center' style='border-collapse:collapse'>";
echo "<tr><th>ID người dùng</th><th>Tên đăng nhập</th><th>Tên hiển thị</th><th>Email</th><th>Gói hiện tại</th><th></th></tr>";
while($row= mysqli_fetch_array($result1))
{
$userid=$row['ID'];
echo '<tr>';
echo '<td>'.$userid.'</td>';
echo '<td>'.$row['user_login'].'</td>';
echo '<td>'.$row['display_name'].'</td>';
echo '<td>'.$row['user_email'].'</td>';
echo "<td><select name='package_$userid' id='package'>";
$sqlcheck="SELECT 1 FROM wp_usermeta WHERE user_id=".$userid." AND meta_key='package_id' LIMIT 1";
$result_check= mysqli_query($conn,$sqlcheck);
if( mysqli_num_rows($result_check)!=0)
{
$sql_metaval="Select meta_value from wp_usermeta where user_id=".$userid." and meta_key='package_id'";
$result_metaval= mysqli_query($conn,$sql_metaval);
while($metaval= mysqli_fetch_array($result_metaval))
{
$val_package=$metaval['meta_value'];
$test="Select post_title, ID from wp_posts where post_type='membership_package' and ID=".$val_package ;
$sql2="Select post_title, ID from wp_posts where post_type='membership_package' and ID<>".$val_package ;
$result_test=mysqli_query($conn,$test);
if(mysqli_num_rows($result_test)==0)
{
echo '<option value="">FREE</option>';
$sql3="Select post_title, ID from wp_posts where post_type='membership_package' and ID<>''";
$packages= mysqli_query($conn,$sql3);
while($pack = mysqli_fetch_assoc($packages)){
echo '<option value="'.$pack['ID'].'">'.$pack['post_title'].'</option>';
}
echo '</select>';
}
else
{
while($row= mysqli_fetch_array($result_test))
{
echo '<option value="'.$val_package.'">'.$row['post_title'].'</option>';
}
$packages= mysqli_query($conn,$sql2);
while($pack = mysqli_fetch_assoc($packages)){
echo '<option value="'.$pack['ID'].'">'.$pack['post_title'].'</option>';
}
echo '<option value="">FREE</option>';
echo '</select>';
}
}
}
else
{
echo '<option value="">FREE</option>';
$sql3="Select post_title, ID from wp_posts where post_type='membership_package' and ID<>''";
$packages= mysqli_query($conn,$sql3);
while($pack = mysqli_fetch_assoc($packages)){
echo '<option value="'.$pack['ID'].'">'.$pack['post_title'].'</option>';
}
echo '</select>';
}
echo "<td><a onclick='return confirmEdit();' href='#' id='update_$userid' class='update_user'>Cập nhật</a></td>";
echo '</tr>';
}
echo "</table></br></div>";
It's appear that some kind of loop has happened in the first else section. I tried to delete the select tag in side that section, all the option appeared inside but still be duplicated like this one
Can someone show me how to solve the duplicate option? This has trouble me for days.
I think the problem because you loop the selected option and not selected options in same select without exclude the select option from query of get not selected options ($sql2).
$test="Select post_title, ID from wp_posts where post_type='membership_package' and ID=".$val_package ;
$sql2="Select post_title, ID from wp_posts where post_type='membership_package' and ID<>".$val_package ;
-------------------------------------------------------
while($row= mysqli_fetch_array($result_test))
{
echo '<option value="'.$val_package.'">'.$row['post_title'].'</option>';
}
$packages= mysqli_query($conn,$sql2);
while($pack = mysqli_fetch_assoc($packages)){
echo '<option value="'.$pack['ID'].'">'.$pack['post_title'].'</option>';
}

Get selected option value which is dynamically generated in a nested loop

Here is the function I am working on. I need to get the selected option which is inside a while loop.
Every time I am trying to get the selected value through select id, it's only getting the last selected value for the rest of the row.
Please help me. How can I get and store the full table data?
function generate_schedule($con,$sy,$year_id){
$time = array(1=>'9:30-11:00',2=>'11:30-1:00',3=>'1:30-3:00',4=>'3:15-4:45');
$days = array(1=>'Sunday',2=>'Monday',3=>'Tuesday',4=>'Wednesday',5=>'Thursday',6=>'Friday',7=>'Saturday');
$rooms=array(1=>'302',2=>'303',3=>'304',4=>'701',5=>'702',6=>'704',7=>'901',8=>'902',9=>'1402',10=>'1405');
$yls=mysqli_query($con,"SELECT * FROM year_level_subject as yls join subjects as s on yls.subj_id=s.subj_id where yls.year_id='$year_id'");
$num=mysqli_num_rows($yls);
$x = 0;
echo '<table class="table table-bordered table-hover" id=" datatable">';
echo '<thead><tr><th>Time</th><th>Days</th><th>Subject</th><th>Teacher</th><th>Room</th></tr></thead>';
while($row=mysqli_fetch_assoc($yls)){
extract($row);
echo '<tr>';
echo '<td><select id ="seltime" ><option value=0>Select Time</option>';
foreach($time as $key => $value) {
echo '<option value='.$key.'>';
echo $value .'</option>';
}
echo '</select></td>';
echo '<td><select class="selday" ><option value=0>Select Day</option>';
foreach($days as $key => $value) {
echo '<option value='.$key.'>';
echo $value .'</option>';
}
echo '</select></td>';
echo '<td>'.$subj_desc.'</td>';
$teach = mysqli_query($con,"SELECT * FROM teachers");
echo '<td><select id="selteacher" onchange="schedata(this)"><option value=0>Select Teacher</option>';
while($row=mysqli_fetch_assoc($teach)){
extract($row);
echo '<option value='.$teach_id.'>'.$teach_fname.' '.$teach_mname.' '.$teach_lname.'</option>';
}
echo '</select></td>';
echo '</select></td>';
echo '<td><select name ="selroom" ><option value=0>Select Room</option>';
foreach($rooms as $key => $value) {
echo '<option value='.$key.'>';
echo $value .'</option>';
}
echo '</select></td>';
echo '</tr>';
}
echo '</table>';
}
you did't give the name atribute to your select element
echo '<td><select id="selteacher" onchange="schedata(this)" >
give a name for this as
echo '<td><select id="selteacher" name="selteacher" onchange="schedata(this)" >

Get ID automatically in input-field after <SELECT> without button click

I have an SQL-database with many tables. Now I would like to create an input-form to be able to get data into the db without writing the entire sql-code every time. And this should work as follows:
All table names are listed in a drop-down menu. After having selected a table name, a new table with 4 columns is created automatically:
The first column of this table simply contains an increasing number.
The second column contains the field-names of the selected table.
In the third column there are empty input fields to enter the values for the database. Only in the third line (=product name) there is a drop-down menu with all product names from the main-table of the db.
The fourth column contains the data type (e.g. int or varchar)
All tables in the database have the same structure in the first 3 columns: the first column contains the table-id, the second column the foreign-key (=master_id) and the third column the product_name.
Up to this point, the script works well with the following 2 php-files (javasql.php and getuser.php):
javasql.php:
enter code here
<!DOCTYPE html>
<html>
<head>
<script>
function showUser(str) {
if (str=="") {
document.getElementById("txtHint").innerHTML="";
return;
}
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
} else { // code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function() {
if (this.readyState==4 && this.status==200) {
document.getElementById("txtHint").innerHTML=this.responseText;
}
}
xmlhttp.open("GET","getuser.php?q="+str,true);
xmlhttp.send();
}
</script>
</head>
<body>
<form>
<select name="users" onchange="showUser(this.value)">
<option value="" class="optdrugs">please select</option>
<?php
include("files/zugriff.inc.php"); // database Access
$sql = "SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE
TABLE_TYPE = 'BASE TABLE' AND TABLE_SCHEMA = 'product'";
$result = mysqli_query($db, $sql);
while ($row = mysqli_fetch_assoc($result)) {
echo '<option class="optdrugs" value="'. $row['TABLE_NAME'] . '">' .
$row['TABLE_NAME']. '</option>';
echo '<br>';
}
?>
</select>
</form>
<br>
<div id="txtHint"><b>Bitte Tabelle auswählen:</b>
<br>
<?php
if (isset($_POST["submit"])) {
$sent = $_POST['sent'];
$q = $_POST['tablename'];
$column_passed = unserialize($_POST['column']); // content of array
$column is passed from getuser.php
foreach ($_POST["insertvalue"] as $key => $value) {
echo $value . "<br>";
$werte[] = "'$value'";
}
$sql="INSERT INTO $q ($column_passed) VALUES (" .
implode(", ", $werte) . ")"; // data entry
mysqli_query($db, $sql);
if (mysqli_affected_rows($db) > 0) {
echo "<h3 style='color:blue'>successful</h3>";
} else {
echo "<h3 style='color:red'>not
successful</h3>";
}
}
?>
</div>
</body>
</html>
enter code here
getuser.php:
<!DOCTYPE html>
<html>
<head>
<style>
table {
width: 100%;
border-collapse: collapse;
}
table, td, th {
border: 1px solid black;
padding: 5px;
}
th {text-align: left;}
</style>
</head>
<body>
<form id="formdatabase" name="formdatabase" action="javasql.php"
method="post">
<input type="hidden" name="sent" value="yes">
<?php
$q = strval($_GET['q']);
$con = mysqli_connect('localhost','root','','product');
if (!$con) {
die('Could not connect: ' . mysqli_error($con));
}
mysqli_select_db($con,"ajax_demo");
$sql="SELECT * FROM $q";
$result = mysqli_query($con,$sql);
$numcols = mysqli_num_fields($result); // gets number of columns in result table
$field = mysqli_fetch_fields($result); // gets the column names from the result table
$data_type_array = array(
1=>'tinyint',
2=>'smallint',
3=>'int',
4=>'float',
5=>'double',
7=>'timestamp',
8=>'bigint',
9=>'mediumint',
10=>'date',
11=>'time',
12=>'datetime',
13=>'year',
16=>'bit',
252=>'text',
253=>'varchar',
254=>'char',
246=>'decimal'
);
$data_type_array = array_flip($data_type_array);
echo "<table>";
echo "<tr>";
echo "<th>" . 'Nr' . "</th><th>" . 'Column names' . "</th>
<th>" . 'Values for db-entry' . "</th><th>" . 'Type' . "</th>";
echo "</tr>";
echo "<tr>";
$nr = 1;
for($x=0;$x<$numcols;$x++):?>
<td><?= $nr; ?></td>
<td><?= $field[$x]->name; ?></td>
<?= $column[] = $field[$x]->name; ?>
<td>
<?php
if ($field[$x]->name == 'Name') { // if-Beginn
?>
<select name="insertvalue[<?= $x; ?>]" id="insertvalue<?=
$x; ?>" size="1" onchange = "javascript:getSelectedRow()">
<?php
include("files/zugriff.inc.php");
$sql = "SELECT * FROM product_main ORDER BY Name";
$result = mysqli_query($db, $sql);
while ($row = mysqli_fetch_assoc($result)) {
echo '<option class="optdrugs" value='. $row['Name'] . '>' .
$row['Name'] . '</option>';
echo '<br>';
}
?>
</select>
<?php
$name_option = "";
} else {
$name_option = "<input type='text' id='insertvalue" . $x . "'
name='insertvalue[" . $x . "]' size='50'>";
echo $name_option;
}
?>
</td>
<?php
$key = array_search($field[$x]->type, $data_type_array);
if($key !== false){
echo "<td>" . $key . "</td>";
}else{
echo "<td>" . $field[$x]->type . "</td>";
}
?>
<td><?= $field[$x]->type; ?></td>
<?= $nr = $nr + 1; ?>
</tr>
<?php endfor;
echo "</table>";
mysqli_close($con);
?>
<input type="hidden" name="tablename" value="<?= $q; ?>">
<input type="hidden" name="column" value="<?php echo htmlentities
(serialize($column)); ?>">
<input type="submit" value="Enter values" name="submit">
</form>
</body>
</html>
Since I need the master_id (= foreign key) in addition to the product-name for database entry, I would like to extend my script, so that the respective master_id is automatically sent to the input field in line 2, when a product-name is selected in line 3 ... without clicking a button. I tried to do this with javascript but it didn´t work. As far as I know, the solution would be to use AJAX but unfortunately, I am not very used to AJAX.
I would be more than happy, if someone could help me to solve this problem!

Submitting multiple database updates via PHP & JQuery

I'm stuck with trying to process multiple mySQL updates at the same time. I have 4 select/optiion boxes that pull entries from a db table. I want to be able to update the db onChange using JQuery. I have managed to get this working with one select module but as soon as I add more it spins out. I know that the main bad code is in db_submit.php but really not sure how else to write it. I know there has to be a cleaner way to do this.
FORM PAGE- INPUT.PHP
<html>
<head>
<script src="../assets/scripts/jquery-2.0.3.min.js"></script>
<script>
function updateDb() {
$.post("db_submit.php", $("#console").serialize());
}
</script>
<?php
include 'db_connect.php';
?>
</head>
<body>
<form id="console">
<select id="frame1" name="frame1" onChange="updateDb()">
<option value="">Select Channel</option>
<?php
$result = mysqli_query($con,"SELECT * FROM feedContent");
while ($row = mysqli_fetch_array($result)) {
echo "<option value='" . $row['url'] . "'>" . $row['name'] . "</option>";
}
?>
</select>
<select id="frame2" name="frame2" onChange="updateDb()">
<option value="">Select Channel</option>
<?php
$result = mysqli_query($con,"SELECT * FROM feedContent");
while ($row = mysqli_fetch_array($result)) {
echo "<option value='" . $row['url'] . "'>" . $row['name'] . "</option>";
}
?>
</select>
<select id="frame3" name="frame3" onChange="updateDb()">
<option value="">Select Channel</option>
<?php
$result = mysqli_query($con,"SELECT * FROM feedContent");
while ($row = mysqli_fetch_array($result)) {
echo "<option value='" . $row['url'] . "'>" . $row['name'] . "</option>";
}
?>
</select>
<select id="frame4" name="frame4" onChange="updateDb()">
<option value="">Select Channel</option>
<?php
$result = mysqli_query($con,"SELECT * FROM feedContent");
while ($row = mysqli_fetch_array($result)) {
echo "<option value='" . $row['url'] . "'>" . $row['name'] . "</option>";
}
?>
</select>
</form>
</body>
<?php
mysqli_close($con);
?>
</html>
PROCESSING PAGE- DB_SUBMIT.PHP
<?php
include 'db_connect.php';
$frame1= mysqli_escape_String($con,$_POST['frame1']);
$frame2= mysqli_escape_String($con,$_POST['frame2']);
$frame3= mysqli_escape_String($con,$_POST['frame3']);
$frame4= mysqli_escape_String($con,$_POST['frame4']);
$query = "UPDATE frameContent SET url='".$frame1."' WHERE name='frame1'";
$query = "UPDATE frameContent SET url='".$frame2."' WHERE name='frame2'";
$query = "UPDATE frameContent SET url='".$frame3."' WHERE name='frame3'";
$query = "UPDATE frameContent SET url='".$frame4."' WHERE name='frame4'";
mysqli_query($con,$query);
mysqli_close($con);
?>
I know that constantly setting the $query variable is causing problems but I'm not sure how else I can do this in the one page. Any help would be much appreciated.
Thanks!
First of all make sure the $queries are concatenated, then terminate each query with a semi-colon. After these you can use mysqli_multi_query to execute all four updates in one call from php.
$query = "UPDATE frameContent SET url='".$frame1."' WHERE name='frame1';";
$query .= "UPDATE frameContent SET url='".$frame2."' WHERE name='frame2';";
$query .= "UPDATE frameContent SET url='".$frame3."' WHERE name='frame3';";
$query .= "UPDATE frameContent SET url='".$frame4."' WHERE name='frame4';";
mysqli_multi_query($con,$query);
I think this might help :) but there's just a little changes within your codes:
<html>
<head>
<script src = "js/jquery-1.10.1.js"></script>
<script>
function updateDb()
{
// this var id will store all your 4 combobox values in an array
var id = [{val1: $("#frame1").val()},
{val1: $("#frame2").val()},
{val1: $("#frame3").val()},
{val1: $("#frame4").val()}];
//this .post will submit all data to db_submit.php
$.post("db_submit.php",{id:id}, function(data)
{
alert(data);
});
</script>
<?php
include 'db_connect.php';
?>
</head>
<body>
<select id="frame1" name="frame1">
<option value="">Select Channel</option>
<?php
$result = mysqli_query($con,"SELECT * FROM feedContent");
while ($row = mysqli_fetch_array($result)) {
echo "<option value='" . $row['url'] . "'>" . $row['name'] . "</option>";
}
?>
</select>
<select id="frame2" name="frame2">
<option value="">Select Channel</option>
<?php
$result = mysqli_query($con,"SELECT * FROM feedContent");
while ($row = mysqli_fetch_array($result)) {
echo "<option value='" . $row['url'] . "'>" . $row['name'] . "</option>";
}
?>
</select>
<select id="frame3" name="frame3">
<option value="">Select Channel</option>
<?php
$result = mysqli_query($con,"SELECT * FROM feedContent");
while ($row = mysqli_fetch_array($result)) {
echo "<option value='" . $row['url'] . "'>" . $row['name'] . "</option>";
}
?>
</select>
<select id="frame4" name="frame4">
<option value="">Select Channel</option>
<?php
$result = mysqli_query($con,"SELECT * FROM feedContent");
while ($row = mysqli_fetch_array($result)) {
echo "<option value='" . $row['url'] . "'>" . $row['name'] . "</option>";
}
?>
</select>
<input type="button" value="Submit" onClick="updateDb()"/>
</body>
<?php
mysqli_close($con);
?>
</html>
And in your DB_SUBMIT.PHP
<?php
include 'db_connect.php';
$frame1= mysqli_escape_String($_POST['id'][0]['val1']);
$frame2= mysqli_escape_String($_POST['id'][1]['val1']);
$frame3= mysqli_escape_String($_POST['id'][2]['val1']);
$frame4= mysqli_escape_String($_POST['id'][3]['val1']);
$query = mysqli_query("UPDATE frameContent SET url='$frame1' WHERE name='frame1'");
$query = mysqli_query("UPDATE frameContent SET url='$frame2' WHERE name='frame2'");
$query = mysqli_query("UPDATE frameContent SET url='$frame3' WHERE name='frame3'");
$query = mysqli_query("UPDATE frameContent SET url='$frame4' WHERE name='frame4'");
echo "Data was Successfully updated";
mysqli_close($con);
?>
I just add a button there for convenience, but if you dont want it just delete it and put back the onChange on every combocboxes that you have :)

Categories

Resources