php - mysql update table ajax by class -


i'm trying update rows quantity using ajax class not id have looked on google hours trying work out find didnt seem work

my code far is

include('config.php');   $id=$_get[id];  $sql2="select *  `orders`  `id` = '".$id."'";  $result2 = mysql_query($sql2);  $row2 = mysql_fetch_array($result2);  $order=$_get[order]; $qty=$_get[qty];  $sql="select *  `stock`  `part` = '".$part."'";  $result = mysql_query($sql);  $row1 = mysql_fetch_array($result);  $lineprice=$qty * $row2[price];  $sqlins1 = "update `orders` set qty='$qty', lineprice='$lineprice' id = '".$id."'";  if (!mysql_query($sqlins1,$con))   {   die('error: ' . mysql_error());   }  $sql="select * `orders`  `invoice` = '".$order."' order id desc";  $result = mysql_query($sql); echo"   <table id='poitable' width='100%' border='1'>         <tr>             <td>sku</td>             <td>qty</td>             <td width='45%'>item</td>             <td>unit price</td>             <td>line price</td>             <td>delete</td>         </tr>"; while($row = mysql_fetch_array($result))   {  echo"<tr><td>" . $row['part'] . "</td><td><form name='test'>    <input type='hidden' value='" . $row[id] . "' id='part'>   <input type='text' id='qty' value='" . $row['qty'] . "' onblur='updateqty(this.id)'></form></td><td>" . $row['description'] . "</td><td>" . $row['price'] . "</td><td>" . $row['lineprice'] . "</td><td> <input type='image' src='images/btn_delete.png' value='" . $row[id] . "' onclick='deletesku(this.value)' height='30'/></td> ";   } 

any on appreciated,

many thanks

  1. your code vulnerable sql injection.
  2. you're using deprecated api not support prepared statements prevent sql injection
  3. you can combine update , select single statement. here's idea
  4. your deduction should database based, not value based

    update tbl update col = col - 1


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -