Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $username = "root";
- $password = "";
- $host = "localhost";
- $connector = mysql_connect($host,$username,$password) or die("Unable to connect");
- $selected = mysql_select_db("diya", $connector)
- or die("Unable to connect");
- //execute the SQL query and return records
- $result = mysql_query("SELECT * FROM items ORDER BY id ASC");
- $result1 = mysql_query("SELECT * FROM items ORDER BY id ASC");
- ?>
- <html>
- <head><title>Modify Item</title>
- </head>
- <body>
- <p>Enter Item ID</p>
- <form class="frm3" method="POST" action="modify.php">
- ID: <input type="text" name="id0" id="id0"><br><br>
- <input type="submit" value="Modify" id="submit">
- <br>_____________________________________________________________________
- </form>
- <?php
- if ( ! empty( $_POST ) ){
- $id=$_POST['id0'];
- }
- while( $row = mysql_fetch_array( $result ) ){
- if($row['id']==$id){ ?>
- <form class="frm" method="POST" action="modify.php">
- <img id="img" name="img" src="<?php echo $row['image'] ?>" height="100" width="100"><br>
- ID: <input id="id1" name="id1" type="text" value=<?php echo $row['id']?> ><br><br>
- NAME: <input id="nme" name="nme" type="text" value=<?php echo $row['name'] ?>><br><br>
- COST: <input id="cost" name="cost" type="text" value=<?php echo $row['cost'] ?>><br><br>
- QUALITY: <input id="qual" name="qual" type="text" value=<?php echo $row['quality']?>><br><br>
- DIAMOND WEIGHT:<input id="dwt" name="dwt" type="text" value=<?php echo $row['dweight']?>><br><br>
- NUMBER OF DIAMONDS: <input id="nod" name="nod" type="text" value=<?php echo $row['nod'] ?>> <br><br>
- GOLD TYPE: <input id="gty" name="gty" type="text" value=<?php echo $row['type'] ?>><br><br>
- PURITY: <input id="pur" name="pur" type="text" value=<?php echo $row['purity'] ?>><br><br>
- GOLD WEIGHT: <input id="gwt" name="gwt" type="text" value=<?php echo $row['gweight'] ?>><br><br>
- DESCRIPTION: <input type="text" id="desc" name="desc" value=<?php echo $row['description'] ?>>
- <br><br><input type="submit" id="save" value="Save">
- </form>
- <?php } }
- $id1=$_POST['id1'];
- $name = $_POST['nme'];
- $cost = $_POST['cost'];
- $quality = $_POST['qual'];
- $dweight = $_POST['dwt'];
- $nod = $_POST['nod'];
- $gtype = $_POST['gty'];
- $purity = $_POST['pur'];
- $gweight = $_POST['gwt'];
- $desc = $_POST['desc'];
- if(! empty($_POST)){
- $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");
- }
- ?>
- </body>
- </html>
Add Comment
Please, Sign In to add comment