Guest User

modify

a guest
Jan 18th, 2016
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.86 KB | None | 0 0
  1. <?php
  2. $username = "root";
  3. $password = "";
  4. $host = "localhost";
  5.  
  6. $connector = mysql_connect($host,$username,$password) or die("Unable to connect");
  7. $selected = mysql_select_db("diya", $connector)
  8. or die("Unable to connect");
  9.  
  10. //execute the SQL query and return records
  11. $result = mysql_query("SELECT * FROM items ORDER BY id ASC");
  12. $result1 = mysql_query("SELECT * FROM items ORDER BY id ASC");
  13.  
  14. ?>
  15.  
  16. <html>
  17. <head><title>Modify Item</title>
  18. </head>
  19.  
  20. <body>
  21. <p>Enter Item ID</p>
  22. <form class="frm3" method="POST" action="modify.php">
  23. ID: <input type="text" name="id0" id="id0"><br><br>
  24. <input type="submit" value="Modify" id="submit">
  25. <br>_____________________________________________________________________
  26. </form>
  27. <?php
  28. if ( ! empty( $_POST ) ){
  29. $id=$_POST['id0'];
  30. }
  31.  
  32. while( $row = mysql_fetch_array( $result ) ){
  33. if($row['id']==$id){ ?>
  34. <form class="frm" method="POST" action="modify.php">
  35. <img id="img" name="img" src="<?php echo $row['image'] ?>" height="100" width="100"><br>
  36. ID: <input id="id1" name="id1" type="text" value=<?php echo $row['id']?> ><br><br>
  37. NAME: <input id="nme" name="nme" type="text" value=<?php echo $row['name'] ?>><br><br>
  38. COST: <input id="cost" name="cost" type="text" value=<?php echo $row['cost'] ?>><br><br>
  39. QUALITY: <input id="qual" name="qual" type="text" value=<?php echo $row['quality']?>><br><br>
  40. DIAMOND WEIGHT:<input id="dwt" name="dwt" type="text" value=<?php echo $row['dweight']?>><br><br>
  41. NUMBER OF DIAMONDS: <input id="nod" name="nod" type="text" value=<?php echo $row['nod'] ?>> <br><br>
  42. GOLD TYPE: <input id="gty" name="gty" type="text" value=<?php echo $row['type'] ?>><br><br>
  43. PURITY: <input id="pur" name="pur" type="text" value=<?php echo $row['purity'] ?>><br><br>
  44. GOLD WEIGHT: <input id="gwt" name="gwt" type="text" value=<?php echo $row['gweight'] ?>><br><br>
  45. DESCRIPTION: <input type="text" id="desc" name="desc" value=<?php echo $row['description'] ?>>
  46. <br><br><input type="submit" id="save" value="Save">
  47. </form>
  48.  
  49. <?php } }
  50.  
  51. $id1=$_POST['id1'];
  52. $name = $_POST['nme'];
  53. $cost = $_POST['cost'];
  54. $quality = $_POST['qual'];
  55. $dweight = $_POST['dwt'];
  56. $nod = $_POST['nod'];
  57. $gtype = $_POST['gty'];
  58. $purity = $_POST['pur'];
  59. $gweight = $_POST['gwt'];
  60. $desc = $_POST['desc'];
  61.  
  62. if(! empty($_POST)){
  63. $sql=mysql_query("UPDATE items SET id='$id1',name='$name',cost='$cost',quality='$quality',dweight='$dweight',nod='$nod',type='$gtype',purity='$purity',gweight='$gweight',description='$desc' WHERE id=$id");
  64. }
  65. ?>
  66. </body>
  67. </html>
Add Comment
Please, Sign In to add comment