I have a small problem of requete mysql I explain I would like to put one day the column "status" via a checkbox by clicking a plus button, then I click the button nothing happens.
I would like to know if my code is good
Requette.php
<?php
/* Database connection start */
$servername = "localhost";
$username = "root";
$password = "Mm101010";
$dbname = "smartphone";
$conn = mysqli_connect($servername, $username, $password, $dbname) or die("Connection failed: " . mysqli_connect_error());
/* Database connection end */
$data_ids = $_REQUEST['data_ids'];
$data_id_array = explode(",", $data_ids);
if(!empty($data_id_array)) {
foreach($data_id_array as $Or_Affectation) {
$sql = "UPDATE abonnements SET Statut = 'Non Affecté' ";
$sql.=" WHERE Or_Affectation = '".$Or_Affectation."'";
$query=mysqli_query($conn, $sql) or die("supr_Affect.php: Suprimer Affectation");
}
}
?>
index.php
<!DOCTYPE html>
<html>
<title>Smartphone</title>
<head>
<link rel="stylesheet" type="text/css" href="css/jquery.dataTables.css">
<link rel="stylesheet" type="text/css" href="css/bouton.css">
<script type="text/javascript" language="javascript" src="js/jquery.js"></script>
<script type="text/javascript" language="javascript" src="js/jquery.dataTables.js"></script>
<script type="text/javascript" language="javascript" >
$(document).ready(function() {
var dataTable = $('#vu_affect_empl').DataTable( {
"processing": true,
"serverSide": true,
"columnDefs": [ {
"targets": 0,
"orderable": false,
"searchable": false
} ],
"ajax":{
url :"Affectation.php", // json datasource
type: "post", // method , by default get
error: function(){ // error handling
$(".vu_affect_empl-error").html("");
$("#vu_affect_empl").append('<tbody class="vu_affect_empl-error"><tr><th colspan="3"></th></tr></tbody>');
$("#vu_affect_empl_processing").css("display","none");
}
}
} );
$("#action_ligne").on('click',function() { // bulk checked
var status = this.checked;
$(".updateRow").each( function() {
$(this).prop("checked",status);
});
});
$('#update_affect').on("click", function(event){ // triggering delete one by one
if( $('.updateRow:checked').length > 0 ){ // at-least one checkbox checked
var ids = [];
$('.updateRow').each(function(){
if($(this).is(':checked')) {
ids.push($(this).val());
}
});
var ids_string = ids.toString(); // array to string conversion
$.ajax({
type: "POST",
url: "supr_Affect.php",
data: {data_ids:ids_string},
success: function(result) {
dataTable.draw(); // redrawing datatable
},
async:false
});
}
});
} );
</script>
<style>
div.container {
margin: 0 auto;
max-width:760px;
}
div.header {
margin: 100px auto;
line-height:30px;
max-width:760px;
}
body {
background: #f7f7f7;
color: #333;
font: 90%/1.45em "Helvetica Neue",HelveticaNeue,Verdana,Arial,Helvetica,sans-serif;
} </style>
</head>
<body>
<h2 align="center">Affectation</h2><br/><br/><br/>
<center>
<button href="Abonnement.php" id="update_affect" class="bouton_dans_page">Abonnement</button>
Employe
Equipement
Modele
Nouvelle Affectation
Employe
Menu Smarphone
<table id="vu_affect_empl" cellpadding="0" cellspacing="0" border="0" class="display" width="100%"><br/><br/><br/><br/>
<thead>
<tr>
<th><input type="checkbox" id='action_ligne' /></th>
<th>USER ID</th>
<th>Nom</th>
<th>Prenom</th>
<th>Num SIM</th>
<th>PIN Terminal</th>
<th>PIN SIM</th>
<th>Num EMEI</th>
<th>Date Debut</th>
<th>Date Fin</th>
<th>Vitre</th>
<th>Coque</th>
<th>Support Vehicule</th>
<th>Actif</th>
<th>Statut</th>
</tr>
</thead>
</table><br><br>
<button type="button" class="Menu" id="update_affect" name="Supprimer_affect">Suprimer Affectation</button>
<button class="Menu" type="button" id="C_R_E" onclick="javascript:Confirmer" name="C_R_E">Confirmer Retour Equipement</button>
Remplacer Equipement
<button class="Menu" type="button" id="A_S_L" name="A_S_L">Ajout et Supression Ligne</button>
<button class="Menu" type="button" id="C_R_A" name="C_R_A">Confirmer Retour Abonnement</button>
<button class="Menu" type="button" id="Reaff_Equip" name="Reaff_Equip">Reaffectation Equipement</button>
</center>
</body>
</html>
thank you
$('.updateRow').each(function(){
if($(this).is(':checked')) {
ids.push($(this).data('yourID'));
}
});
I think that you are passing the wrong information regarding the ID's you need (you are using ids.push($(this).val()); and if the value of the checkbox does not contain the ID needed you will not get anything).
EDIT:
Change the class of the checkbox at line:
$nestedData[] = "<input type='checkbox' class='deleteRow' value='".$row['Or_Affectation']."' /> N°".$i ;
to
$nestedData[] = "<input type='checkbox' class='updateRow' value='".$row['Or_Affectation']."' /> N°".$i ;
Yes of course
<?php
$servername = "localhost";
$username = "root";
$password = "Mm101010";
$dbname = "smartphone";
$conn = mysqli_connect($servername, $username, $password, $dbname) or die("Connection failed: " . mysqli_connect_error());
$requestData = $_REQUEST;
$columns = array(
0 => 'USER_ID',
1 => 'Nom',
2 => 'Prenom',
3 => 'Num_SIM',
4 => 'PIN_Terminal',
5 => 'PIN_SIM',
6 => 'Num_IMEI',
7 => 'Date_Debut',
8 => 'Date_Fin',
9 => 'Vitre',
11 => 'Coque',
12 => 'Support_Vehicule',
13 => 'Actif',
14 => 'Statut'
);
$sql = "SELECT Or_Affectation ";
$sql.=" FROM vu_affect_empl";
$query=mysqli_query($conn, $sql) or die("Affectation.php: get employees");
$totalData = mysqli_num_rows($query);
$totalFiltered = $totalData;
$sql = "SELECT Or_Affectation, USER_ID, Nom, Prenom, Num_SIM, PIN_Terminal, PIN_SIM, Num_IMEI, Date_Debut, Date_Fin, Vitre, Coque, Support_Vehicule, Actif, Statut ";
$sql.=" FROM vu_affect_empl WHERE 1=1";
if( !empty($requestData['search']['value']) ) {
$sql.=" AND ( USER_ID LIKE '".$requestData['search']['value']."%' ";
$sql.=" OR Num_SIM LIKE '".$requestData['search']['value']."%' ";
$sql.=" OR Nom LIKE '".$requestData['search']['value']."%' )";
}
$query=mysqli_query($conn, $sql) or die("Affectation.php: get employees");
$totalFiltered = mysqli_num_rows($query);
$sql.=" ORDER BY ". $columns[$requestData['order'][0]['column']]." ".$requestData['order'][0]['dir']." LIMIT ".$requestData['start']." ,".$requestData['length']." ";
$query=mysqli_query($conn, $sql) or die("Affectation.php: get employees");
$data = array();
$i=1+$requestData['start'];
while( $row=mysqli_fetch_array($query) ) {
$nestedData=array();
$nestedData[] = "<input type='checkbox' class='updateRow' value='".$row['Or_Affectation']."' /> N°".$i ;
$nestedData[] = $row["USER_ID"];
$nestedData[] = $row["Nom"];
$nestedData[] = $row["Prenom"];
$nestedData[] = $row["Num_SIM"];
$nestedData[] = $row["PIN_Terminal"];
$nestedData[] = $row["PIN_SIM"];
$nestedData[] = $row["Num_IMEI"];
$nestedData[] = $row["Date_Debut"];
$nestedData[] = $row["Date_Fin"];
$nestedData[] = $row["Vitre"];
$nestedData[] = $row["Coque"];
$nestedData[] = $row["Support_Vehicule"];
$nestedData[] = $row["Actif"];
$nestedData[] = $row["Statut"];
$data[] = $nestedData;
$i++;
}
$json_data = array(
"draw" => intval( $requestData['draw'] ),
"recordsTotal" => intval( $totalData ),
"recordsFiltered" => intval( $totalFiltered ),
"data" => $data
);
echo json_encode($json_data);
?>
Related
I need fa fa-star class's mouseenter, mouseout, and onclick function work for each specific 'list' class/li tag(like list class[0, 1, 2, etc]). What I have now is working for every 'list' class. When I mouseenter on a star from different list class the 1st list class's star is changing.
If I mouseenter on a star from 1st list class/li tag the mouseenter function should work for that list class/li tag not for other 'list' class/li tag. if 2nd 'list' class then it should work for that 'list' class/li tag not for others. and for 3rd, 4th etc.
in rateclick function I can send the rating to server but can't fetch it. Can you look into it also?
Here is the code:
index.php and style.css
.fa{
font-size:25px;
}
li{
list-style:none;
padding-left:40px;
padding-bottom:40px;
border-bottom:2px solid #ccc;
width:800px;
}
li:last-child{
border-bottom:none;
}
<?php
require "conx.php";
$sql = "SELECT * FROM customers ORDER BY id ASC";
$query = $conx -> query($sql);
$numrows = $query -> num_rows;
?>
<!DOCTYPE html>
<html>
<link rel="stylesheet" href="css/font-awesome.min.css">
<link rel="stylesheet" href="style.css">
<script src="jquery.min.js"></script>
<body>
<div class="Insert-Into">
<ul>
<?php if($numrows > 0): ?>
<?php while($row = $query -> fetch_assoc()): ?>
<?php $rating = $row["rating"]; ?>
<?php $customerid = $row["id"]; ?>
<li data-rating=<?php echo "$rating"; ?> data-customerid=<?php echo $customerid; ?> class="list">
<br/>
<br/>
<span class="username"><?php echo $row["username"]; ?></span>
<br/>
<br/>
<?php
$i;
$color;
for($i = 1; $i <= 5; $i++){
if($i <= $rating){
$color = "color:orange";
}
else{
$color = "color:#ccc";
}
echo "<i class='fa fa-star' style='$color;' data-rating='$i' onmouseenter='mouseenterrating($i)' onmouseout='clearstar($rating)' onclick='rateclick($customerid, $i)'></i>";
}
?>
<br/>
<br/>
<b>Description</b>
<br/>
<br/>
<div class="desc"><?php echo $row["description"]; ?></div>
</li>
<?php endwhile; ?>
<?php endif; ?>
</ul>
</div>
<script>
function mouseenterrating(count){
var j;
var fa = document.getElementsByClassName("fa");
for(j = 0; j < fa.length; j++){
if(j < count){
fa[j].style.color = "orange";
}
else{
fa[j].style.color = "#ccc";
}
}
}
function clearstar(rating){
var fa = document.getElementsByClassName("fa");
var k;
for(k = 0; k < fa.length; k++){
if(k < rating){
fa[k].style.color = "orange";
}
else{
fa[k].style.color = "#ccc";
}
}
}
function rateclick(customerid, count){
var xhttp = new XMLHttpRequest();
xhttp.open("POST", "rating.php?id="+customerid+"&rate="+count);
xhttp.send();
fetch(customerid);
}
function fetch(e){
var xhttp = new XMLHttpRequest();
xhttp.open("GET", "fetch.php");
xhttp.send();
}
</script>
</body>
</html>
rating.php
<?php
require "conx.php";
if(isset($_GET['id']) && isset($_GET['rate'])){
$customerid = $_GET['id'];
$rate = $_GET['rate'];
$sql = "UPDATE customers SET rating = '$rate' WHERE id = '$customerid'";
$result = $conx -> query($sql);
}
?>
fetch.php
<?php
require "conx.php";
$sql = "SELECT * FROM customers WHERE id = '".customerid."'";
$result = $conx -> query($sql);
$fetch = $result -> fetch_assoc();
?>
conx.php
<?php
$conx = mysqli_connect("localhost", "root", "");
if(!$conx){
echo "Not connected with localhost";
}
$sql = "CREATE DATABASE rating";
$query = $conx -> query($sql);
$dbselect = $conx -> select_db("rating");
if(!$dbselect){
echo "No database selected";
}
$sql = "CREATE TABLE customers(id INT(255) NOT NULL AUTO_INCREMENT UNIQUE KEY, username VARCHAR(200) NOT NULL, description VARCHAR(1000) NOT NULL, email VARCHAR(200) NOT NULL PRIMARY KEY, rating INT(5) NOT NULL)";
$query = $conx -> query($sql);
?>
Building on your initial attempt I have this solution for you:
function onMouseEnter(index){
var fa = document.getElementsByClassName("fa");
var j;
for(j = 0; j < fa.length; j++){
if(j < index){
fa[j].style.color = "orange";
}
else{
fa[j].style.color = "#ccc";
}
}
}
function onMouseOut(){
var fa = document.getElementsByClassName("fa");
var k;
for(k = 0; k < fa.length; k++){
fa[k].style.color = "#ccc";
}
}
Demo
Here when I click post button it inserts a random value on database.
If a value already exists on database then show error. It works fine.
But I want to add 2/3 characters at the end of value if it already exists on database. If $check == 1 then I want to add some characters at the end of the value instead of showing alert. How to do this?
<?php
$con = mysqli_connect("localhost","root","","post") or die("unable to connect to internet");
if(isset($_POST['submit']))
{
$slug = $_POST['rand'];
$get_slug = "select * from slug where post_slug='$slug' ";
$run_slug = mysqli_query($con,$get_slug );
$check = mysqli_num_rows($run_slug );
// if $check==1 then i want to add 2 characters at the end of $slug .
if($check == 1)
{
// instead of showing alert i want to add 2 more characters at the end of that value and and insert it on database
echo "<script> alert('something is wrong') </script> ";
exit ();
}
else
{
$insert ="insert into slug (post_slug) values ('$slug') ";
$run = mysqli_query($con,$insert);
if($run)
{
echo "<p style='float:right;'> Posted successfully </p>";
}
}
}
?>
<form method="POST" >
<?php
$result = "";
$chars = "abcdefghijklmnopqrstuvwxyz0123456789";
$chararray = str_split($chars);
for($i = 0; $i < 7 ; $i++)
{
$randitem = array_rand($chararray);
$result .= "".$chararray[$randitem];
}
echo $result ;
?>
<input type="hidden" value="<?php echo $result;?>" name="rand" />
<span class="input-group-btn">
<button class="btn btn-info" type="submit" name="submit">POST</button>
</span>
</form>
just run update query if $check == 1
if($check == 1){
$newSlug = $slug."xy";
$update = "update slug set post_slug = '".$newSlug."' where post_slug = '".$slug."'";
$run = mysqli_query($con,$update );
echo "<script> alert('Updated Successfully') </script> ";
exit ();
}
This is helpful for you
<?php
$con = mysqli_connect("localhost","root","","post" ) or die
( "unable to connect to internet");
if(isset($_POST['submit'])){
$tmp_slug = $_POST['rand'];
$slug = $_POST['rand'];
while(check_exiest($tmp_slug))
{
$tmp_rand = rand(11,99);
$tmp_slug = $slug.$tmp_rand;
}
$insert ="insert into slug (post_slug) values ('$tmp_slug') ";
$run = mysqli_query($con,$insert);
if($run)
{
echo "<p style='float:right;'> Posted successfully </p>";
}
}
public function check_exiest($slug)
{
$get_slug = "select * from slug where post_slug='$slug' ";
$run_slug = mysqli_query($con,$get_slug );
$check = mysqli_num_rows($run_slug );
if($check >= 1)
{
return true;
}
else
{
return false;
}
}
?>
Just few modification in your code to insert new value.
<?php
$con = mysqli_connect("localhost","root","","post") or die("unable to connect to internet");
if(isset($_POST['submit']))
{
$slug = $_POST['rand'];
$get_slug = "select * from slug where post_slug='$slug' ";
$run_slug = mysqli_query($con,$get_slug );
$check = mysqli_num_rows($run_slug );
if($check == 1)
{
$slug_new = $slug.'ab'; // Add 2 characters at the end
$update ="UPDATE slug SET post_slug = '$slug_new' WHERE post_slug = '$slug'";
$run = mysqli_query($con,$update);
}
else
{
$insert ="insert into slug (post_slug) values ('$slug') ";
$run = mysqli_query($con,$insert);
if($run)
{
echo "<p style='float:right;'> Posted successfully </p>";
}
}
}
?>
when i gonna for search about row the result search and show in the current page
how to make live search on a table with all paging ?
don't tell me show us what you have done
the result is table with paging each page content table with 5 rows
filterTable.js
(function(document) {
'use strict';
var LightTableFilter = (function(Arr) {
var _input;
function _onInputEvent(e) {
_input = e.target;
var tables = document.getElementsByClassName(_input.getAttribute('data-table'));
Arr.forEach.call(tables, function(table) {
Arr.forEach.call(table.tBodies, function(tbody) {
Arr.forEach.call(tbody.rows, _filter);
});
});
}
function _filter(row) {
var text = row.textContent.toLowerCase(), val = _input.value.toLowerCase();
row.style.display = text.indexOf(val) === -1 ? 'none' : 'table-row';
}
return {
init: function() {
var inputs = document.getElementsByClassName('form-control');
Arr.forEach.call(inputs, function(input) {
input.oninput = _onInputEvent;
});
}
};
})(Array.prototype);
document.addEventListener('readystatechange', function() {
if (document.readyState === 'complete') {
LightTableFilter.init();
}
});})(document);
Show_Product.php
<input type="search" class="form-control" data-table="table-striped table-bordered table-hover" id="autocomplete" name="search">
<table class="table table-striped table-bordered table-hover">
</table>
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "msk";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$query = "select p.productname,p.quantity,p.onesale,p.wholesale,s.fullname from productdetails p , supplier s where s.supplierid = p.supplierID";
$resultt = $conn->query($query);
$total_records = mysqli_num_rows($resultt);
$per_page=5;
if (isset($_GET["page"])) {
$page = $_GET["page"];
}
else {
$page=1;
}
$start_from = ($page-1) * $per_page;
$total_pages = ceil($total_records / $per_page);
echo "<div class=\"widget-foot\">";
echo "<ul class=\"pagination pagination-sm pull-right\" dir=\"rtl\">";
if($page<$total_pages) {
echo "<li><a href='Show_Product.php?page=" . ($page + 1) . "'>Next</a></li>";
}
for ($i=$total_pages; $i>=1; $i--) {
echo "<li><a href='Show_Product.php?page=".$i."'>".$i."</a></li>";
};
if($page>1){
echo "<li><a href='Show_Product.php?page=".($page-1)."'>Previous</a></li>";
}
echo"</ul>";
echo"<div class=\"clearfix\"></div>";
$conn ->close();
?>
I want to display how many keys and value in each row in a td tag, but in my second td tag display the first and second row.. and then also the third...
How can I display first row in a first td tag, and 2nd row in 2nd td tag? Here's my code so far:
<table>
<thead>
<tr>
<th>Rows</th>
</tr>
</thead>
<tbody>
<?php
$query = "SELECT from_monday, from_tuesday, from_wednesday,from_thursday, from_friday, to_monday, to_tuesday,to_wednesday, to_thursday, to_friday from tabletest ORDER BY survey_id DESC LIMIT 4";
$result = mysql_query($query, $connection);
if($result === FALSE) { die(mysql_error()); }
while($details = mysql_fetch_array($result))
{
$newArray = array_count_values($details) ;
foreach ($newArray as $key => $value)
{
$newValue = $value/2;
$key = trim(addslashes($key));
$newValue = preg_replace('/\D/', '', $newValue);
$myurl[] = "['".$key."', ".$newValue."]";
}
echo "<tr><td>";
echo implode(",", $myurl);
echo "</td></tr>";
}
?>
</tbody>
</table>
You are storing data in an array it mean it will contain previous values as well on each loop iteration, you need to reset the array on each iteration
$myurl = array();
try following code
<?php
$query = "SELECT from_monday, from_tuesday, from_wednesday,from_thursday, from_friday, to_monday, to_tuesday,to_wednesday, to_thursday, to_friday from tabletest ORDER BY survey_id DESC LIMIT 4";
$result = mysql_query($query, $connection);
if($result === FALSE) { die(mysql_error()); }
while($details = mysql_fetch_array($result))
{
$newArray = array_count_values($details) ;
$myurl = array();
foreach ($newArray as $key => $value)
{
$newValue = $value/2;
$key = trim(addslashes($key));
$newValue = preg_replace('/\D/', '', $newValue);
$myurl[] = "['".$key."', ".$newValue."]";
}
echo "<tr><td>";
echo implode(",", $myurl);
echo "</td></tr>";
}
?>
When I edit row in grid, changes show only in this grid. But when I reload grid all updates disappear, because data hasn't been updated in database
who can prompt where I was mistaken.
here my test.html
<script type="text/javascript" src="js/jquery.js"></script>
<script src="js/i18n/grid.locale-ru.js" type="text/javascript"></script>
<script src="js/i18n/grid.locale-en.js" type="text/javascript"></script>
<script src="js/jquery.jqgrid.min.js" type="text/javascript"></script>
<script src="js/grid.common.js" type="text/javascript"></script>
<script src="js/grid.formedit.js" type="text/javascript"></script>
<script type="text/javascript">
$(function(){
$('#table').jqGrid({
url:'test.php',
datatype: 'json',
mtype: 'POST',
height: 500,
colNames:['Код страны','Код региона', 'Город','Долгота','Широта','nbip'],
colModel :[
{name:'country_code', index:'country_code', width:80, editable:true, edittype:'text'},
{name:'region_code', index:'region_code', width:180, editable:true, edittype:'text'},
{name:'city', index:'city', width:190, editable:true, edittype:'text'},
{name:'latitude', index:'latitude', width:160, editable:true, edittype:'text'},
{name:'longitude', index:'longitude', width:160, editable:true, edittype:'text'},
{name:'nbip', index:'nbip', width:130, editable:true, edittype:'text'}],
pager: $('#tablePager'),
pgtext : "Page {0} of {1}",
rowNum:100,
rowList:[10,20,30,100],
sortname: 'city',
sortorder: 'asc',
caption: 'Загрузка JSON данных',
rownumbers: true,
rownumWidth: 40
});
jQuery("#table").jqGrid('navGrid','#tablePager',
{edit:true,add:true,del:true,search:true}, //options
{url:'edit.php', height:280,reloadAfterSubmit:false, closeAfterEdit: true}, // edit options
{height:280,reloadAfterSubmit:false}, // add options
{reloadAfterSubmit:false}, // del options
{} // search options
);
}
});
</script>
</head>
<body>
<table id="table"></table>
<div id="tablePager"></div>
</form>
</body>
</html>
test.php
<?php
$db = mysql_connect($db_host, $db_login, $db_passwd);
mysql_select_db($db_name);
$page = $_POST['page'];
$limit = $_POST['rows'];
$sidx = $_POST['sidx'];
$sord = $_POST['sord'];
if(!$sidx) $sidx =1;
$result = mysql_query("SELECT COUNT(*) AS count FROM cities");
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$count = $row['count'];
if( $count > 0 && $limit > 0) {
$total_pages = ceil($count/$limit);
} else {
$total_pages = 0;
}
if ($page > $total_pages) $page=$total_pages;
$start = $limit*$page - $limit;
if($start <0) $start = 0;
$query = "SELECT id, country_code, region_code, city, latitude, longitude, nbip FROM cities ORDER BY ".$sidx." ".$sord." LIMIT ".$start.", ".$limit;
$result = mysql_query($query);
$data->page = $page;
$data->total = $total_pages;
$data->records = $count;
$i = 0;
while($row = mysql_fetch_assoc($result)) {
$data->rows[$i]['id'] = $row[id];
$data->rows[$i]['cell'] = array($row[country_code],$row[region_code],$row[city],$row[latitude],$row[longitude],$row[nbip]);
$i++;
}
header("Content-type: text/script;charset=utf-8");
echo json_encode($data);
?>
edit.php
$db = mysql_connect($db_host, $db_login, $db_passwd) or die("Connection Error: " . mysql_error());
mysql_select_db($db_name) or die("Error conecting to db.");
//mysql_query("SET NAMES 'utf8'");
// And so on for the other form values
$id = $_POST['id'];
$country_code = mysql_real_escape_string($_POST['country_code']);
$region_code = mysql_real_escape_string($_POST['region_code']);
$city = $_POST['city'];
$latitude = mysql_real_escape_string($_POST['latitude']);
$longitude = mysql_real_escape_string($_POST['longitude']);
$nbip = mysql_real_escape_string($_POST['nbip']);
if($_POST['oper']=='add'){
// mysql insert
}else if($_POST['oper']=='edit'){
// mysql update
$query = "UPDATE cities SET city = '".$city."' WHERE id = ".$id;
$result = mysqli_query($db,$query) or die(mysql_error());
break;
}else if($_POST['oper']=='del'){
// mysql delete
}
?>
Thanks.
you are using mysqli for data updates and using mysql_real_escape_string, mysql_connect, mysql_select_db in your code as well.
update your code to use only mysqli instead of using both mysql and mysqli